谁能给我一个完整的VB循环灯程序!!谢谢了

来源:百度知道 编辑:UC知道 时间:2024/06/08 20:25:14
我不怎么会,你们能帮帮我吗,写下来,谢谢你们了,设计一个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