谁能给我一个完整的VB循环灯程序!!谢谢了
我不怎么会,你们能帮帮我吗,写下来,谢谢你们了,设计一个5个等循环闪烁的程序,每间隔1秒亮一个!!
参考答案:窗体上放Shape控件数组和Timer控件,代码如下
Option Explicit
Dim sum As Byte
Private Sub Form_Load()
Timer1.Interval = 1000
End Sub
Private Sub Timer1_Timer()
sum = sum + 1
If sum = 1 Then
Shape1(0).Visible = True
Shape1(1).Visible = False
Shape1(2).Visible = False
Shape1(3).Visible = False
Shape1(4).Visible = False
ElseIf sum = 2 Then
Shape1(1).Visible = True
Shape1(0).Visible = False
Shape1(2).Visible = False
Shape1(3).Visible = False
Shape1(4).Visible = False
ElseIf sum = 3 Then
Shape1(2).Visible = True
Shape1(0).Visible = False
Shape1(1).Visible = False
Shape1(3).Visible = False
Shape1(4).Visible = False
ElseIf sum = 4 Then
Shape1(3).Visible = True
Shape1(0).Visible = False
Shape1(2).Visible = False
Shape1(1).Visible = False
Shape1(4).Visible = False
ElseIf sum >= 5 Then
sum = sum - 5
Shape1(4).Visible = True
Shape1(0).Visible = False
Shape1(2).Visible = False
Shape1(3).Visible = False
Shape1(1).Visible = False
End If
End Sub