Hi,
I have a user form to get some input from the user and want to make sure that in some textboxes user should be able enter only text i.e A to Z or a-z no numbers or special charecters.
i tried searching the threads and got this
Code
Private Sub CommandButton1_Click()
Dim RegEx As Object
Dim Strng As String
Strng = CStr(Me.TextBox1.Value)
Set RegEx = CreateObject("vbscript.regexp")
With RegEx
.Pattern = "^[A-Z]{2}/\d+/\d{2}$"
If Not .test(Strng) Then MsgBox "Invalid Format: TextBox1"
End With
Set RegEx = Nothing
End Sub
Display More
i modified it to
Code
Sub Commandcheck()
Dim RegEx As Object
Dim Strng As String
Strng = CStr(TextBox2.Value)
Set RegEx = CreateObject("vbscript.regexp")
With RegEx
.Pattern = "[A-Z]"
If Not .test(Strng) Then MsgBox "Invalid Format: TextBox1"
End With
Set RegEx = Nothing
End Sub
Display More
but this only accepts captial alphabets i.e A,B,C.... and not a,b,c...
please help