Monday, 4 April 2016

Lab 6:Write a Visual Basic Program to Show Traffic Light

Dim a As Integer

Private Sub Form_Load()
Shape1.BackColor = vbRed
Shape2.BackColor = vbWhite
Shape3.BackColor = vbWhite
End Sub

Private Sub Timer1_Timer()
a = a + 1
If a = 7 Then
Shape1.BackColor = vbWhite
Shape2.BackColor = vbYellow
Shape3.BackColor = vbWhite
End If
If a = 14 Then
Shape1.BackColor = vbWhite
Shape2.BackColor = vbWhite
Shape3.BackColor = vbGreen
End If
If a = 21 Then
Form_Load
a = 0
End If

End Sub

No comments:

Post a Comment