472,802 Members | 1,419 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,802 software developers and data experts.

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 8535
208 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

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

Similar topics

by: Gremlin | last post by:
If you are not familiar with the halting problem, I will not go into it in detail but it states that it is impossible to write a program that can tell if a loop is infinite or not. This is a...
by: Vedran Vukotic | last post by:
Hello I made the following infinite loop that check's if the bot died and call it again: ------loadloop.pl----- #!/usr/bin/perl use strict; while (1) {
by: jojobar | last post by:
I have a aspx file (snippet shown below): ======= <td class="light-m1" id="rwCompleteButton" runat="server"><br/> <asp:ImageButton CssClass="clear-m1" runat="server" CommandName="Complete"...
by: Sunbags | last post by:
Hello, I'm a 2nd year Computer Engineering student and I have a problem with my VB6 code. I've just started learning VB6 for a project in which we have to create a form which displays the...
by: James Watt | last post by:
can anyone tell me how to do an infinite loop in C/C++, please ? this is not a homework question .
by: razer | last post by:
Hi everybody I'm making a project where i need to make a simulation of a traffic light. The cars appear randomly, and are represented by letter, the traffic light stays open for x seconds, then...
by: anusha sharma | last post by:
i have made a visual basic project for traffic light,all the 3 lights are working properly....i need to insert a timer alongwith them,which should decrement each step for specific light.....as soon...
by: harryred7 | last post by:
Hi Question- I am currently writing a VB program for a traffic light control system. It nothing too robust nor with any microprocessors/sensors. i am using a Timer to control when the lights...
by: initdebug | last post by:
To start, I'm a complete beginner with Computer Vision and I made this project following multiple tutorials. I wanted to create a simple program that would take any input video (in my case, my...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
by: lllomh | last post by:
How does React native implement an English player?
by: Mushico | last post by:
How to calculate date of retirement from date of birth

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.