0
namespace CountDown

    public partial class Form1 : Form
    {
        public int counter = 0;

        public Form1()
        {
            InitializeComponent();
        }

         private void btnStart_Click(object sender, EventArgs e)
        {
            int parsedValue;

            if (!int.TryParse(txtInput.Text, out parsedValue))
            {
                MessageBox.Show("Please Enter Numbers Only");
            }
            else
            {
                counter = Convert.ToInt32(txtInput.Text);

                timer1 = new Timer();
                timer1.Tick += new EventHandler(timer2_Tick);
                timer1.Interval = 1000 * 60; // 1 second converts to 1 minute by adding * 60

                timer1.Start();
                lblDisplay.Text = counter.ToString();

                lblDisplay.Text = txtInput.Text;
                lblDisplay.Visible = true;
            }
        }

        private void timer2_Tick(object sender, EventArgs e)
        {
            counter--;
            if (counter == 0)

            timer1.Stop();
            lblDisplay.Text = counter.ToString();
        }
    }

Edited by Thobani_1

2
Contributors
3
Replies
10
Views
10 Months
Discussion Span
Last Post by rproffitt
0

Forgot to post a follow up question but thats the code am using to do a count down timer in MINUTES. I need to also display minutes and seconds at the same time. MIN:SEC. Please help

0

Wait, do you need some formula to show text from an integer of seconds to minutes? That seems something rather basic.

That is, are you asking folk to code this for you?

PS. I'm sure you are seeing more and more folk ask for code. In this discussion you appear to be asking for code you expect a first year coder to be able to handle.

Q. What's eluding you here? Is it the math or somethign else?

Edited by rproffitt

This topic has been dead for over six months. 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.