Private Function RegExpTest(StrText, Pattern)
Dim regex
Set regex = CreateObject("VBScript.RegExp")
regex.Pattern = Pattern
regex.Global = True
RegExpTest = regex.Test(StrText)
Set regex = Nothing
End Function
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii <> 8 And Not RegExpTest(Chr(KeyAscii), "[a-z]|[A-Z]") Then
KeyAscii = 0
End If
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii < Asc("A") Or KeyAscii > Asc("Z") And KeyAscii < Asc("a") Or KeyAscii > Asc("z") Then KeyAscii = 0
End Sub