|
-
April 6th, 2001, 03:37 PM
#1
KeyPress Numeric enforcing
I am using a textbox and using the keypress event
to make the characters uppercase.
I have another textbox that I am using that I want
to ignore all characters except numerics. What
value should the KeyAscii variable be set to.
In addition I want to have the escape sequence characters not be affected. A tab should go to the next control in the tab order.
Any thoughts??
-
April 6th, 2001, 03:50 PM
#2
Re: KeyPress Numeric enforcing
Private Sub Text1_KeyPress(KeyAscii As Integer)
Const Numbers$ = "0123456789."
If InStr(Numbers, Chr(KeyAscii)) = 0 Then
KeyAscii = 0
Exit Sub
End If
End Sub
Tab will send you to the next control
Iouri Boutchkine
[email protected]
-
April 6th, 2001, 08:13 PM
#3
Re: KeyPress Numeric enforcing
It's always faster to manipulate numbers than strings. So, a better method will be
private Sub Text1_KeyPress(KeyAscii as Integer)
If KeyAscii >= 48 and KeyAscii <= 57 then KeyAscii = 0
End Sub
48 is the code for "0" and 57 for "9"
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
|