Timer Countdown

Please support our C# advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Feb 2008
Posts: 39
Reputation: mr_scooby is an unknown quantity at this point 
Solved Threads: 0
mr_scooby mr_scooby is offline Offline
Light Poster

Timer Countdown

 
0
  #1
Dec 27th, 2008
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
  1. timer1.Interval = 1000;
  2. timer1.Enabled = true;

here is the code inside the timer_Tick
  1. 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.
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 2,065
Reputation: Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice 
Solved Threads: 256
Featured Poster
Ramy Mahrous's Avatar
Ramy Mahrous Ramy Mahrous is offline Offline
Postaholic

Re: Timer Countdown

 
0
  #2
Dec 27th, 2008
You should have integral value decreases each time tick

  1. int tik = 30;
  2. private void timer1_Tick(object sender, EventArgs e)
  3. {
  4. if (tik >= 0)
  5. label1.Text = (tik--).ToString();
  6. else
  7. label1.Text = "Stopped";
  8. }
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
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 39
Reputation: mr_scooby is an unknown quantity at this point 
Solved Threads: 0
mr_scooby mr_scooby is offline Offline
Light Poster

Re: Timer Countdown

 
0
  #3
Dec 28th, 2008
cool thx dude, this is what i needed in total

  1. if (tik >= 0)
  2. {
  3. timerlbl.Text = (tik--).ToString();
  4. }
  5. else
  6. {
  7. timerlbl.Text = "Out of Time";
  8. unAnswered++;
  9. lblCountUnanswered.Text = unAnswered.ToString();
  10. timer1.Stop();
  11. tik = 5;
  12. }
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C# Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC