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();
}
}
Thobani_1 -2 Newbie Poster
rproffitt 2,662 "Nothing to see here." Moderator
Thobani_1 -2 Newbie Poster
rproffitt 2,662 "Nothing to see here." Moderator
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.