#2
wds12018-09-19 15:19
|
程序加载时显示为红灯。想请教:在timer1_timer()中,如果不加exit sub,倒计时绿灯为什么从9开始,黄灯为什么从1开始
程序如下:
只有本站会员才能查看附件,请 登录
Dim x%
Private Sub Command1_Click()
Timer1.Enabled = True
End Sub
Private Sub Command2_Click()
Timer1.Enabled = False
End Sub
Private Sub Form_Load()
Call Option1_Click
End Sub
Private Sub Option1_Click()
Shape1.Visible = True
Shape2.Visible = False
Shape3.Visible = False
x = 5
Label1.Caption = x
Label1.ForeColor = vbRed
End Sub
Private Sub Option2_Click()
Shape1.Visible = False
Shape2.Visible = True
Shape3.Visible = False
x = 2
Label1.Caption = x
Label1.ForeColor = vbYellow
End Sub
Private Sub Option3_Click()
Shape1.Visible = False
Shape2.Visible = False
Shape3.Visible = True
x = 10
Label1.Caption = x
Label1.ForeColor = vbGreen
End Sub
Private Sub Timer1_Timer()
If Option1.Value Then
x = x - 1
If x < 0 Then Option3.Value = True: Exit Sub
End If
If Option3.Value Then
x = x - 1
If x < 0 Then Option2.Value = True: Exit Sub
End If
If Option2.Value Then
x = x - 1
If x < 0 Then Option1.Value = True: Exit Sub
End If
Label1.Caption = x
End Sub