| | |
Timer Countdown
Please support our C# advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Feb 2008
Posts: 39
Reputation:
Solved Threads: 0
Hi, I am trying to add a timer countdown of 30 secs to a form I have made.
Here is the code inside the start button
here is the code inside the timer_Tick
what happens tho is this is displayed:
[System.Window.Forms.Timer], interval: 1000
I can't seem to work out hot to start the count at 30 and work my way down every second, any pointers in the right direction would be cool thx
Here is the code inside the start button
C# Syntax (Toggle Plain Text)
timer1.Interval = 1000; timer1.Enabled = true;
here is the code inside the timer_Tick
C# Syntax (Toggle Plain Text)
timerlbl.Text = timer1.ToString();
what happens tho is this is displayed:
[System.Window.Forms.Timer], interval: 1000
I can't seem to work out hot to start the count at 30 and work my way down every second, any pointers in the right direction would be cool thx
Last edited by mr_scooby; Dec 27th, 2008 at 8:09 pm.
You should have integral value decreases each time tick
C# Syntax (Toggle Plain Text)
int tik = 30; private void timer1_Tick(object sender, EventArgs e) { if (tik >= 0) label1.Text = (tik--).ToString(); else label1.Text = "Stopped"; }
Last edited by Ramy Mahrous; Dec 27th, 2008 at 9:16 pm.
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
•
•
Join Date: Feb 2008
Posts: 39
Reputation:
Solved Threads: 0
cool thx dude, this is what i needed in total
C# Syntax (Toggle Plain Text)
if (tik >= 0) { timerlbl.Text = (tik--).ToString(); } else { timerlbl.Text = "Out of Time"; unAnswered++; lblCountUnanswered.Text = unAnswered.ToString(); timer1.Stop(); tik = 5; }
![]() |
Similar Threads
- Visual Basic Timer/Clock/Countdown. (Visual Basic 4 / 5 / 6)
- countdown timer: time limit from database (C#)
- timer countdown help (Visual Basic 4 / 5 / 6)
- Timer Countdown (C++)
- Countdown to a date (Visual Basic 4 / 5 / 6)
- Countdown (Java)
Other Threads in the C# Forum
- Previous Thread: how to get a value in javascript from aspx to aspx.cs
- Next Thread: default choice of ComboBox
| Thread Tools | Search this Thread |
.net access ado.net algorithm array backup barchart bitmap box broadcast buttons c# check checkbox client clock color combobox control conversion csharp custom database datagrid datagridview dataset datetime degrees development draganddrop drawing dynamiccreation encryption enum event excel file form format forms function game gdi+ httpwebrequest image index input install interface java label list listbox mandelbrot math microsystems mouseclick mysql operator password path photoshop picturebox pixelinversion post programming property radians regex remote remoting richtextbox running... serialization server sleep soap socket sql sqlserver stack statistics stream string table text textbox thread time timer update usercontrol validation visualstudio webbrowser windows winforms wpf write xml






