使用vb写一个模拟红绿灯的程序?
1个回答
展开全部
Dim r As Integer, g As Integer, y As Integer
Private Sub Form_Load()
Timer1.Enabled = True
Timer2.Enabled = False
Timer3.Enabled = False
Label1.Caption = 0
Label2.Caption = 0
Label3.Caption = 0
Image2.Picture = LoadResPicture(1000, vbResBitmap)
Image1.Picture = LoadResPicture(1000, vbResBitmap)
Image3.Picture = LoadResPicture(1000, vbResBitmap)
g = 60 + 1
End Sub
Private Sub Timer1_Timer()
Image1.Picture = LoadResPicture(1001, vbResBitmap)
Image2.Picture = LoadResPicture(1000, vbResBitmap)
Image3.Picture = LoadResPicture(1000, vbResBitmap)
g = g - 1
Label1.Caption = g
If g = 0 Then
y = 3 + 1
Timer1.Enabled = False
Timer2.Enabled = True
End If
End Sub
Private Sub Timer2_Timer()
Image2.Picture = LoadResPicture(1003, vbResBitmap)
Image1.Picture = LoadResPicture(1000, vbResBitmap)
Image3.Picture = LoadResPicture(1000, vbResBitmap)
y = y - 1
Label2.Caption = y
If y = 0 Then
r = 60 + 1
Timer2.Enabled = False
Timer3.Enabled = True
End If
End Sub
Private Sub Timer3_Timer()
Image3.Picture = LoadResPicture(1002, vbResBitmap)
Image2.Picture = LoadResPicture(1000, vbResBitmap)
Image1.Picture = LoadResPicture(1000, vbResBitmap)
r = r - 1
Label3.Caption = r
If r = 0 Then
g = 60 + 1
Timer3.Enabled = False
Timer1.Enabled = True
End If
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询