I need to validate a certain textbox input to only accept numerical data between the range of 0-10 and so that is shows an error message in a label when the button is pushed and the data isn't within those specifications. This then clears the textbox, focuses the textbox and exits the sub routine if the data is invalid.
Current code is:
Select Case decScore1
Case txtScore1.Text = ""
strScore1Error = "Score 1 is blank"
lblStatusShow.Text = strScore1Error
txtScore1.Clear()
txtScore1.Focus()
Exit Sub
Case Not IsNumeric(txtScore1.Text)
strScore1Error = "Score 1 is not a numeric value: 0-10"
lblStatusShow.Text = strScore1Error
txtScore1.Clear()
txtScore1.Focus()
Exit Sub
Case decScore1 > 10 Or decScore1 < 0
strScore1Error = "Score 1 is not in the range: 0-10"
lblStatusShow.Text = strScore1Error
txtScore1.Clear()
txtScore1.Focus()
Exit Sub
Case Else
strScore1Error = "Score 1 input is valid"
End Select`
The issues are:
If txtScore1 is left blank, lblStatusShow = "Score 1 is not in the range: 0-10" when I need it to have the text "Score 1 is blank"
If txtScore1 is not a numeric value, lblStatusShow = "Score 1 is blank"
If txtScore1 is outside of the range 0-10, lblStatusShow = "Score 1 is valid"
So essentially it's not validating in the right way at all and I'm not sure why or how to fix it.