Code skips the error if statements and goes straight to the else if
I need laps to go through and if its less than 2 then it'll go to the error and come back again to ask to enter a new value. vice versa for greater than 20. Im a new programmer and find C# Windows Forms hard to understand
int.TryParse(txtNumberOfLaps.Text, out laps);
while (laps < 2 && laps > 20)
{
if (laps < 2)
{
MessageBox.Show("Laps can't be less than 2", "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else if (laps > 20)
{
MessageBox.Show("Laps can't be more than 20", "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else if (laps > 2 && laps < 20)
{
break;
}
}