|
-
Oct 7th, 2000, 06:17 PM
#1
Thread Starter
Fanatic Member
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
-
Oct 7th, 2000, 06:39 PM
#2
-
Oct 8th, 2000, 01:00 AM
#3
Thread Starter
Fanatic Member
Thanks-a-gig
That did it!
JO
-
Oct 8th, 2000, 01:18 AM
#4
Even easier:
Code:
Private Sub Text1_KeyPress(KeyAscii As Integer)
If IsNumeric(Chr(KeyAscii)) <> True Then KeyAscii = 0
End Sub
-
Oct 8th, 2000, 06:53 AM
#5
Frenzied Member
Matthew, that'll not work if the user backspaces, spaces or use the arrow buttons.
Use this instead:
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
It's pretty easy too!
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
-
Oct 9th, 2000, 03:54 PM
#6
Thread Starter
Fanatic Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|