I wanna make a textbox only accept number input,what shall I do?
Source code may make me easier :P
Printable View
I wanna make a textbox only accept number input,what shall I do?
Source code may make me easier :P
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
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.