用VB编写“红绿灯”程序

来源:百度知道 编辑:UC知道 时间:2024/07/02 17:49:43
最简单的那种,不用很难的,就和路上红绿灯一样,有数字在跳的那种,简单点的
一楼说的我也知道

很简单,拖放1个text,用来显示数字,3个shape,作为红绿黄灯,3个timer,分别控制红灯、绿灯、黄灯,代码写在timer控件中就行了。

请教这句VB代码哪里出错了啊?!在线等,急!!!
Image1.Picture = LoadPicture(″E:\红绿灯\红灯.jpg″)

Dim s As Integer

Dim n As Integer

'单击“红灯”按钮

Private Sub Command1_Click()

Shape6.Visible = True : Shape7.Visible = False : Shape8.Visible = False

End Sub

'单击“黄灯”按钮

Private Sub Command2_Click()

Shape6.Visible = False : Shape7.Visible = True : Shape8.Visible = False

End Sub

'单击“绿灯”按钮

Private Sub Command3_Click()

Shape6.Visible = False : Shape7.Visible = False : Shape8.Visible = True

End Sub

'单击“自动”按钮

Private Sub Command4_Click()

Timer1.Enabled = True

Command1.Enabled = False

Command2.Enabled = False

Command3.Enabled = False

n = 0 : s = 0

End Sub

'单击“手动”按钮
<