|
-
April 30th, 2001, 01:48 AM
#1
Restrict input of a textbox to numbers
I wanna make a textbox only accept number input,what shall I do?
Source code may make me easier :P
-
April 30th, 2001, 02:06 AM
#2
Re: Restrict input of a textbox to numbers
Hi,
you could use this code:
private Sub Text1_KeyPress(KeyAscii as Integer)
Select Case KeyAscii
Case Asc("0") to Asc("9")
Case else:
KeyAscii = 0
End Select
End Sub
Bye,
O.K
-
April 30th, 2001, 05:46 AM
#3
Re: Restrict input of a textbox to numbers
private Sub Text1_KeyPress(KeyAscii as Integer)
if keyAscii=8 then exit sub
if not isNumeric(chr(KeyAscii)) then
KeyAscii=0
end if
End Sub
the ascii value of BackSpace is 8.
isnumeric is a function used to check whether the value is numeric or not.
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
|