Well if you know how to stop numbers, you know how to stop letters!
Code:'stop numbers Private Sub Text1_KeyPress(KeyAscii As Integer) If (IsNumeric(Chr(KeyAscii))) Then KeyAscii = 0 End SubThis does't remove all the other possible characters, such as puntuation and control characters.Code:'stop letters Private Sub Text1_KeyPress(KeyAscii As Integer) If Not (IsNumeric(Chr(KeyAscii))) Then KeyAscii = 0 End Sub
But you can check for the values between 0 and 58 and then over 122 and simply eliminate them.
This will give you only letters.Code:Private Sub Text1_KeyPress(KeyAscii As Integer) If KeyAscii > 0 or KeyAscii < 58 Then KeyAscii = 0 Else If KeyAscii > 122 Then KeyAscii = 0 EndIf End Sub
The numbers are the decimal Ascii number corresponding to the character. 32 is a space.
See your VB help, there is an Ascii chart in it.




Reply With Quote