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

timer1.Interval = 1000;
timer1.Enabled = true;

here is the code inside the timer_Tick

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

2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by mr_scooby
0

You should have integral value decreases each time tick

int tik = 30;
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (tik >= 0)
                label1.Text = (tik--).ToString();
            else
                label1.Text = "Stopped";
        }
0

cool thx dude, this is what i needed in total

if (tik >= 0)
            {
                timerlbl.Text = (tik--).ToString();
            }
            else
            {
                timerlbl.Text = "Out of Time";
                unAnswered++;
                lblCountUnanswered.Text = unAnswered.ToString();
                timer1.Stop();
                tik = 5;
            }
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.