不知道是不是你要的答案:
新建窗体,添加一个时间控件,一个label控件
Private Sub Form_Load()
Label1.Caption = ""
Timer1.Interval = 1000
End Sub
Private Sub Timer1_Timer()
Static s
s = s + 1
t = s
Label1 = t & "秒"
If t >= 10 Then
s = 0
End If
If t <= 3 Then
Label1 = t & "秒" & "绿灯行"
End If
If t > 3 Then
Label1 = t & "秒" & "注意"
End If
If t > 5 Then
Label1 = t & "秒" & "红绿灯"
End If
If t >= 9 Then
Label1 = t & "秒" & "注意"
End If
End Sub
Private Sub Command1_Click() '开始按钮
Timer1.Enabled = True
Timer1_Timer
End Sub
Private Sub Timer1_Timer() '计时开始
Static s
s = s + 1
If s <= 3 Then
Label1.BackColor = vbGreen
Else
Label1.BackColor = &H8000000F
End If
If s > 3 And s <= 5 Then
Label2.BackColor = vbYellow
Else
Label2.BackColor = &H8000000F
End If
If s > 5 And s <= 8 Then
Label3.BackColor = vbRed
Else
Label3.BackColor = &H8000000F
End If
If s > 8 And s <= 10 Then
Label2.BackColor = vbYellow
ElseIf s > 5 And s < 8 Then
Label2.BackColor = &H8000000F
End If
If s = 11 Then
s = 0
End If
Label4.Caption = s & "秒" '显示当前秒数
End Sub
'label1 2 3 分别表示红黄绿