I'm unsure of what's wrong with this code. The timer1 interval is set to 1000.
namespace timerbug
{
public partial class Form1 : Form
{
int value;
public Form1()
{
InitializeComponent();
}
private void timer1_Tick(object sender, EventArgs e)
{
do
{
value++;
label1.Text = value.ToString();
}
while (value <= 5);
}
private void button1_Click(object sender, EventArgs e)
{
value = 0;
timer1.Start();
}
}
}
I thought the label would display 1 to 5, then stop. The counting doesn't even show up until 6, and continues to go up until I stop the program. Can someone explain why the numbers 1 to 5 are not showing up, and then why it doesn't stop at 5? Thank you.