1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

[vb] Do until a button is clicked?

Discussion in 'Software Development' started by fongweibin, May 4, 2011.

Thread Status:
Not open for further replies.
Advertisement
  1. fongweibin

    fongweibin Thread Starter

    Joined:
    May 4, 2011
    Messages:
    1
    hi there im a beginner in vb, im doing a traffic light system right now. i have build the code, but don't know how to loop the whole thing. The condition is like the following:
    -There are three traffic lights, each goes and another follows after the previous one turns red.
    -im now trying "do until (exitbutton.selected)" ..."loop" ---> doesnt return a value, i know there is a mistake here
    the loop should continue running until user click on the exit button.
    anyone can help me? im using a timer by the way, and i have declared the variable "count" to count the timer. should i add "count = 0" at the last part of the loop in order to let the count starts from zero again?

    sorry i know ive explained quite poorly. Please feel free to ask more thank you :)
     
  2. DaBeers

    DaBeers

    Joined:
    Oct 30, 2008
    Messages:
    276
    There are just a few things you need to do to make a timer work.

    Drop a timer on the form.

    Set the increment.
    Code:
    [FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2]
    Timer1.Interval = 100
    [/SIZE][/FONT][/SIZE][/FONT]
    (1000 = 1 second)

    Tell it to start.
    Code:
    [FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2]
    Timer1.Start()
    [/SIZE][/FONT][/SIZE][/FONT]
    Then you can use the Timer1.Ticks event to run code at your selected interval.

    GL
     
  3. centauricw

    centauricw

    Joined:
    Jun 26, 2010
    Messages:
    444
    You should be using the Button.Click event to capture the exit button click. It can then set a variable to show the exit button has been clicked. You watch this variable in your loop and exit the loop when the variable is set.
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/995104