Last month I asked how to get a leveling up system in VB.Net, which worked wonderfully. My problem now is that if a user tries to enter any string (including a mix of characters) it does nothing for the level box, instead of catching the user out. My current code is as follows:
ElseIf txtExperience.Text = "" Or txtExperience.Text = Letters Then
MessageBox.Show("Input must be a whole number between 0 and 100000", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
I vaguely remember doing something similar to this when I was first learning VB.Net, however I no longer have access to that program and I can't seem to find anything which might catch the user when entering any letters into the box.
This is probably some nooby mistake, but thanks for any help you might be able to give :)
Have you tried something like;
For Each c As Char in txtExperience.Text
If Char.IsDigit(c) = False Then
MsgBox("Only digits are allowed - Character " & c & " is not valid")
Exit Sub
End If
Next
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments