Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Only numbers in a textBox

Status
Not open for further replies.

Grog9999

Technical User
Nov 10, 2002
6
CA
I've got a textbox that will only need integer. How can I do to make it impossible to write anything else than numbers into it?????
 
use this
Private Sub on VALUE_KeyPress()

If keyascii <> 8 Then
keyascii = IIf(Chr(keyascii) Like &quot;[0-9]&quot;, keyascii, 0)
End If

End Sub
 
Private Sub txtInteger_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case 8, 9, 13
exit sub
Case Else
if Chrw(keyAscii) Like &quot;[0-9]&quot; then exit sub
KeyAscii = 0
End Select
End Sub
Forms/Controls Resizing/Tabbing Control
Compare Code (Text)
Generate Sort Class in VB or VBScript
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top