yeah it is in a Button Click Event.
In that case, you should not need to code a loop at all. Just
Exit Sub after displaying the messagebox.
- If IsNumeric(txtWind.Text) = False Or Val(txtWind.Text) < 0 Or Val(txtWind.Text) > 25 Then
-
MsgBox("Please Enter Positive numbers only!")
-
Exit Sub
-
End If
No need for an ELSE, because control has now exited from this whole routine back to just waiting for user interaction.
One other small point - your displayed message doesn't accurately reflect the situation. If I enter "26" it will tell me I must enter a positive number. "But I just
did!". It's not good programming practice to confuse your user. That's the sort of thing which makes people hate computers, and the earlier you break the habit, the better.