流水灯vb程序,用滚动条控制灯光变化速度
1个回答
展开全部
很简单,我来给你做啊
联系我,baidu hi
控件:一组共15个Command1控件数组(Style设置为1), Label1, HScroll1, Timer1
代码:
Dim i As Integer, j As Integer
Private Sub Form_Load()
With HScroll1
.Max = 1000
.LargeChange = 200
.SmallChange = 50
.Value = 500
End With
Label1.Caption = HScroll1.Value
Timer1.Interval = HScroll1.Value
For j = 0 To 14
Command1(j).BackColor = vbGreen
Next
End Sub
Private Sub HScroll1_Change()
If HScroll1.Value = 0 Then HScroll1.Value = 50
Timer1.Interval = HScroll1.Value
Label1.Caption = HScroll1.Value
End Sub
Private Sub Timer1_Timer()
On Error Resume Next
Command1(i - 1).BackColor = vbGreen
Command1(i).BackColor = vbRed
Command1(i).SetFocus
i = i + 1
If i = 15 Then i = 0: Command1(14).BackColor = vbGreen
End Sub
调试:
VB6调试通过
联系我,baidu hi
控件:一组共15个Command1控件数组(Style设置为1), Label1, HScroll1, Timer1
代码:
Dim i As Integer, j As Integer
Private Sub Form_Load()
With HScroll1
.Max = 1000
.LargeChange = 200
.SmallChange = 50
.Value = 500
End With
Label1.Caption = HScroll1.Value
Timer1.Interval = HScroll1.Value
For j = 0 To 14
Command1(j).BackColor = vbGreen
Next
End Sub
Private Sub HScroll1_Change()
If HScroll1.Value = 0 Then HScroll1.Value = 50
Timer1.Interval = HScroll1.Value
Label1.Caption = HScroll1.Value
End Sub
Private Sub Timer1_Timer()
On Error Resume Next
Command1(i - 1).BackColor = vbGreen
Command1(i).BackColor = vbRed
Command1(i).SetFocus
i = i + 1
If i = 15 Then i = 0: Command1(14).BackColor = vbGreen
End Sub
调试:
VB6调试通过
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询