Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

[code] Sub Textbox1_KeyPress (keya 1

Status
Not open for further replies.

JohnYingling

Programmer
Mar 24, 2001
3,742
US
Code:
Sub Textbox1_KeyPress (keyascii as integer)
    If KeyAscii = 8 then exit function ' Backspace
    If Not(Chr(KeyAscii) Like "[a-zA-Z]") Then keyascii = 0 
End Sub
 
Hi,

Since there isn't a question pending I'll assume you want the code to be debugged so:

Private Sub Text1_KeyPress(KeyAscii As Integer)
'You can still use the if-thens but...
Select Case KeyAscii
Case 8
Exit Sub 'notice exit sub not function
Case 65 To 91, 97 To 122 'not sure like can be used
KeyAscii = 0
End Select
End Sub

Have a good one!
BK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top