Visual Basic > Forms
Enter Key working as Tab
Enter Key working as Tab Public Sub AllowNumbersOnly(KeyAscii As Integer) 'PROCEDURE TO RESTRICT THE INPUT IN A TEXT BOX TO 'NUMBERS 'USED IN THE KEY_PRESS EVENT HANDLER 'THIS SUB ALSO SETS THE ENTER KEY AS TAB KEY TO MOVE FOCUS Select Case KeyAscii Case 13 KeyAscii = 0 SendKeys "{tab}" Case Asc("A") To Asc("z"), 32 To 47, 58 To 64, 124 To 258 ' invalid charecters so beep Dim i As Integer For i = vbKey0 To 20 Beep Next i KeyAscii = 0 End Select Exit Sub End Sub and call it Private sub text1_KeyPress(KeyAscii As Integer) Call AllowNumbersOnly(KeyAscii) End Sub
Visual Basic Codes
ActiveX
Miscellaneous
Applications
Code Snippets
Common Dialogs
Special Effects
Database Stuff
Date Time
Files Drives
Forms
Graphics Games
Internet Stuff
Multimedia
Other
Strings
Windows