Ok, I've made a textbox which MUST contain 4 numbers. If there are 3 numbers (or less) you'll get an error or something. I already changed the tabindex to 4. Does someone know how to accomplish this?
Printable View
Ok, I've made a textbox which MUST contain 4 numbers. If there are 3 numbers (or less) you'll get an error or something. I already changed the tabindex to 4. Does someone know how to accomplish this?
You can use the Len function to check the length of the textbox.
Above code can be used after a buttonclick or TextBox1_TextChanged to check instantly.Code:Dim what As String = TextBox1.Text
If Len(what) < 4 Then
MsgBox("no go")
Else
MsgBox("correct size")
End If
Paul
You can also check if a number has been entered in the KeyPress event. If it is not a number set e.Handled to true (unless it is backspace chr(8)).
Thanks both for your help! Hakka's method worked for me though.