how can i constrain the user keyb to only letters and numbers
thnks
Printable View
how can i constrain the user keyb to only letters and numbers
thnks
Paste this code in your Keypress event
[vbocde]
Private Sub Text1_KeyPress(KeyAscii As Integer)
KeyAscii = OnlyRealText(Keyassic)
End Sub
Public Function OnlyRealText(Key As Integer) As Integer
Select Case Key
Case 48 To 57 'Numeric
OnlyRealText = Key
Case 65 To 90 'UpperCase Letters
OnlyRealText = Key
Case 97 To 122 'LowerCase Letters
OnlyRealText = Key
Case 8, 13 'Backspace and Enter
OnlyRealText = Key
Case Else
Key = 0
End Function
[/vbcode]