For a school project i am making a quiz in vb. Im having trouble implimenting a countdown timer so that i could specify an amount of time before an action is taken.

for example when a button is clicked there is 20 seconds before the next question is moved onto.

Ive found pleanty of information on counting down to set dates etc but would really appreciate it if anyone could point me in the right direction.


Use a timer control. Set The interval to 20 seconds (20000, it goes in milliseconds), and when the timer control fires, you know 20 seconds have elapsed. Another solution, is to have the timer execute every 1 second (1000), and then keep an integer variable. Set The integer variable to 20 right off the bat, and every time the timer fires it's event (every second) decrement the variable: variable = variable - 1
Then do an if statement, and test the value of the variable. If it's 0, 20 seconds have passed. You could do this with a label, also, and set the caption of the label to the value of the variable in the timer event. This would show the user how much time is left, and keep your program in count.

I would post code, but I don't use vb.net (I don't like it's syntax). I use VB6... but the concept is still the same. So if you need any further assistance... just let me know.

Thanks so much you wouldnt believe how much this has helped.