website header Blogger Guwl

Open Question: I am trying to make a timer in C# and it is not working, help please?

I have gotten this solution off the internet and adapted it to suit my program. private void buttonPlay_Click(object sender, EventArgs e) { panel1.Enabled = true; buttonAnswer.Enabled = true; { if (paused != true) { if ((textBox1.Text != "") && (textBox2.Text != "") && (textBox3.Text != "")) { timer1.Enabled = true; buttonPause.Enabled = true; buttonPlay.Enabled = false; buttonStop.Enabled = true; textBox1.Enabled = false; textBox2.Enabled = false; textBox3.Enabled = false; textBox4.Enabled = false; try { minutes = System.Convert.ToInt32(textBox2.Text); seconds = System.Convert.ToInt32(textBox1.Text); hours = System.Convert.ToInt32(textBox3.Text); } catch (Exception ex) { MessageBox.Show(ex.Message); } } else { MessageBox.Show("Incomplete settings!"); } } else { timer1.Enabled = true; paused = false; buttonPause.Enabled = false; buttonPause.Enabled = true; } } } private void buttonPause_Click(object sender, EventArgs e) { timer1.Enabled = false; paused = true; buttonPause.Enabled = false; buttonPlay.Enabled = true; } private void buttonStop_Click(object sender, EventArgs e) { paused = false; timer1.Enabled = false; buttonPause.Enabled = false; buttonStop.Enabled = false; buttonPlay.Enabled = true; textBox1.Clear(); textBox2.Clear(); textBox3.Clear(); textBox4.Clear(); textBox1.Enabled = true; textBox2.Enabled = true; textBox3.Enabled = true; textBox4.Enabled = true; labelhrs.Text = "00"; labelmins.Text = "00"; labelsecs.Text = "00"; } private void timer1_Tick(object sender, EventArgs e) { if ((hours == 0) && (minutes == 0) && (seconds == 0)) { timer1.Enabled = false; MessageBox.Show(textBox4.Text); buttonPause.Enabled = false; buttonStop.Enabled = false; buttonPlay.Enabled = true; textBox2.Clear(); textBox3.Clear(); textBox4.Clear(); textBox1.Enabled = true; textBox2.Enabled = true; textBox3.Enabled = true; textBox4.Enabled = true; textBox1.Enabled = true; labelhrs.Text = "00"; labelmins.Text = "00"; labelsecs.Text = "00"; } else { if (seconds < 1) { seconds = 59; if (minutes == 0) { minutes = 59; if (hours != 0) hours -= 1; } else { minutes -= 1; } } else seconds -= 1; labelhrs.Text = hours.ToString(); labelmins.Text = minutes.ToString(); labelsecs.Text = seconds.ToString(); } } Can you see anything wrong?
Home - Privacy Policy