KeyPress Code (1 Viewer)

Voltron

Defender of the universe
Local time
Today, 09:53
Joined
Jul 9, 2009
Messages
77
Here is some code that will only allow the user to hit the backspace key, upper and lowercase letters and integers. You can adjust this by simply taking out sections or simply taking out specific keys.


Private Sub txtUserID_KeyPress(KeyAscii As Integer)

Select Case KeyAscii 'Allows users to use ONLY integers 0-9 and all capital letters as well as the backspace, except for vowels
Case 48 To 57 'integers
Case 65 To 90 'UPPERCASE LETTERS
Case 97 To 122 'lowercase letters
Case vbKeyBack
Case Else
KeyAscii = 0
Exit Sub
End Select
 

Users who are viewing this thread

Top Bottom