I have a text box that the user must enter a number into; How do I format the text box to only accept numbers?
Thanks,
JO
Printable View
I have a text box that the user must enter a number into; How do I format the text box to only accept numbers?
Thanks,
JO
check out this thread, maybe it will help:
http://forums.vb-world.net/showthrea...threadid=29729
Thanks-a-gig
That did it!
JO
Even easier:
Code:Private Sub Text1_KeyPress(KeyAscii As Integer)
If IsNumeric(Chr(KeyAscii)) <> True Then KeyAscii = 0
End Sub
Matthew, that'll not work if the user backspaces, spaces or use the arrow buttons.
Use this instead:
It's pretty easy too!Code:Private Sub Text1_KeyPress(KeyAscii As Integer)
'1 to 32 are system keys (del, space, tab, ctrl + V/C/Z, etc.)
If KeyAscii < 33 Then Exit Sub
If Not (IsNumeric(Chr(KeyAscii))) Then KeyAscii = 0
End Sub
Thanks!!!!!
JO