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

Recommended Answers

All 2 Replies

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";
        }

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;
            }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.