Link to home
Start Free TrialLog in
Avatar of jbakerstull
jbakerstull

asked on

Access Alphabetical Characters Keypress

Working on function that only allows characters & backspace keystrokes in text box.

I'm calling function on keypress event

KeyAscii = CLimitTextInput(KeyAscii)   'Calling CLimitTextInput function.

When I test function, I do receive the error message if a numeric value is pressed, but when I type a character it does not appear in text box.  

 
 
Function CLimitTextInput(KeyAscii) As Integer
      Select Case KeyAscii
        ' 65 To 90 and 97 To 122: These are all alphas, upper and lowercase
        ' 8 Backspace, 9 Tab Key, 32 Space Key
    Case 65 To 90, 97 To 122, 8, 9, 32
    Case Else
        'Setting KeyAscii to zero cancels the key input
        KeyAscii = 0
        MsgBox ("Only Alphabetical Characters Allowed")
        Exit Function
    End Select
   End Function

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Jim Dettman (EE MVE)
Jim Dettman (EE MVE)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jbakerstull
jbakerstull

ASKER

Thank you.