' Force numbers only in a text box
' place this in the 'Keypress' event of a text box
' -------------
' 1st Method
' -------------
Const Number$ = "0123456789." ' only allow these characters
If KeyAscii <> 8 Then
If InStr(Number$, Chr(KeyAscii)) = 0 Then
KeyAscii = 0
Exit Sub
End If
End If
' -------------
' 2nd Method
' -------------
' Force numbers only in a text box
If IsNumeric(Chr(KeyAscii)) <> True Then KeyAscii = 0
Share:
These icons link to social bookmarking sites where readers can share and discover new web pages.
