啊啊啊啊啊啊知道怎么用VB做红绿灯啊简单的那种就行!
1个回答
展开全部
Dim T As Integer, redT As Integer, greenT As Integer, yellowT As Integer
Private Sub Form_Load()
For i = 0 To 2
Shape1(i).BackStyle = 0
Next i
redT = 30
greenT = 30
yellowT = 3
Text1.Text = ""
Timer1.Interval = 1000
T = -1
End Sub
Private Sub Timer1_Timer()
T = T + 1
If T >= 0 And T < redT Then
Shape1(0).BackStyle = 1
Shape1(1).BackStyle = 0
Shape1(2).BackStyle = 0
Shape1(0).BackColor = vbRed
Text1.ForeColor = vbRed
Text1.Text = redT - T
ElseIf T >= redT And T < redT + greenT Then
Shape1(0).BackStyle = 0
Shape1(1).BackStyle = 0
Shape1(2).BackStyle = 1
Shape1(2).BackColor = vbGreen
Text1.ForeColor = vbGreen
Text1.Text = redT + greenT - T
ElseIf T >= redT + greenT And T < redT + greenT + yellowT Then
Shape1(0).BackStyle = 0
Shape1(1).BackStyle = 1
Shape1(2).BackStyle = 0
Shape1(1).BackColor = vbYellow
Text1.ForeColor = vbYellow
Text1.Text = redT + greenT + yellowT - T
Else
T = -1
End If
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询