TimerControl

Lanc1988

Contributor
Joined
Nov 27, 2003
Messages
508
I have been looking for how to program a TimerControl to be a countdown timer from 20 minutes when you click a "Start" button. And also to stop and reset when you click a "Stop" button.

My TimerControl is called "SkullTimer"

Could someone please point me in the right direction by posting a link to a site that explains how to do it or could you post the code, thanks.
 
The timer works in milliseconds, so as 1000 milliseconds = 1 second, you'll need to set it to 1000 * 60 * 20 = whatever it is.

Then enable it.
 
but i need it to display and update in a Label box. Whats the code for that?

And do you mean in properties window type "1000 * 60 * 20 = 120000"? Or do I enter code for it in the Timer code?
 
in the timer_interval event (Set the interval to 1000)

Declare a variable at the top

Private intTotal as Integer

Code:
intTotal = intTotal + 1000
Label1.Text = intTotal 
if intTotal = 120000 then
    'Do what you wanted
end if
 
whats the intTotal? its underlining it in blue in the code editor. do i need to change it to the timer's name?
 
Lanc1988 said:
whats the intTotal? its underlining it in blue in the code editor. do i need to change it to the timer's name?

NO sorry. I should have explained more. I guess I assumed you knew a bit of VB.NET.

What you're doing is setting the timer event to fire every 1000 MS (1 second). As you want something to happen after 120000 MS, we count the number of Milliseconds each second, and display the time in the label.

The outline in blue probably means you didn't declare the variable properly. This is pretty basic stuff though, I recommend getting a VB in 21 days or a similar introduction book, cos otherwiese you'll spend ALOT of time pulling your hair out and not getting very far.
 
I bought a beginner book called "Step by Step" but it doesn't have anything about countdown timers. Only timers used to display the time.
 
Just start simple and work your way to yuor goal. Try and count TO 20 minutes, instead of counting down. Try updating the label with each tick.

To add the code double click on the timer control.
 
Ok.. i guess if i can figure out how to get it to count to 20 mins then eventually i can figure out how to countdown from it.
 
Back
Top