470,590 Members | 2,428 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,590 developers. It's quick & easy.

Traffic light and infinite loop countdown

Pls I have programmed a traffic light on visual basic 6.0 but I cant seem to program the countdown(10-0) to be on infinite loop at every light i.e it should countdown from 10 to 0 before each light shows.
Here is my code
Private Sub Timer2_Timer()
If Label1. Caption = 0 Then
Timer2.Enabled = False
MsgBox ("go")
Label1. Caption = Label1. Caption - 1
End If
End Sub

the countdown continues to 1,-2,-3,-4 and so on but I want it to start from 10 again after counting from 10 to 0..pls how do I put it on endless loop on visual basic 6.0
Jan 26 '22 #1
1 7231
199 Expert 128KB
Reset the Caption to 10:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Timer2_Timer()
  3.     If Label1.Caption = 0 Then
  4.         MsgBox ("go")
  5.         Label1.Caption = "10"
  6.     Else
  7.         Label1.Caption = Label1.Caption - 1
  8.     End If
  10. End Sub
Jan 29 '22 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

43 posts views Thread by Gremlin | last post: by
reply views Thread by Vedran Vukotic | last post: by
44 posts views Thread by James Watt | last post: by
8 posts views Thread by razer | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.