Monday 7 October 2013

Traffic Light Code with Timer

Form Design -

  1. Select 3 shape on the form 
  2. Click on shape properties and select shape - Circle.
  3. Click on shape properties and select Fill Style - Solid.
  4. Click on shape properties and select Fill Color - Red, Yellow, Green.
  5. Select Timer form toolbox.
  6. Click on Timer properties and feel interval time 1500. 

Code -

Private Sub Timer1_Timer()
If Shape1.Visible Then
Shape2.Visible = True
Shape1.Visible = False
Shape3.Visible = False
ElseIf Shape2.Visible Then
Shape3.Visible = True
Shape2.Visible = False
Shape1.Visible = False
Else
Shape1.Visible = True
Shape2.Visible = False
Shape3.Visible = False
End If
End Sub


 

No comments:

Post a Comment