KeyPress Code (1 Viewer)

Voltron

Defender of the universe
Local time
Today, 12:22
Joined
Jul 9, 2009
Messages
77
This code is for anyone who wants to limit the user to which keys they are able to use for data entry.

Private Sub myTextbox(i_KeyAscii As Integer)
Select Case i_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 'Backspace
Case Else
i_KeyAscii = 0 'Sets Ascii value to Null, disallowing the use of the any keys that are not listed in the Case section of the function
Exit Sub
End Select
End Sub
 

Users who are viewing this thread

Top Bottom