Hello this is my first time in this forum as I have just started to learn Visual Basic in school, I have a decent understanding of it however as I dabbled with it a bit for fun. My question is that I have an If statement that I am using to validate if a number is within a range and if it is I do nothing, however the Else statement will display an error message. The program so far works but is it correct to have an if statement without any code that is run if its true and only runs if it is false? I appreciate any help you guys could give me on this or even a suggestion on another way to write this code that may make more sense.
Code:
Sub NumCars()
intNumCars = CInt(txtNumCars.Text)
If intNumCars >= 0 And intNumCars <= 500 Then
' Everything checks out so we can continue
Else
MessageBox.Show("Number of cars must be between 0 and 500.")
txtNumCars.Focus()
txtNumCars.SelectAll()
End If
End Sub