In a textbox how do i test to see if it contains an '@' symbol '.com' and for a date to see if it has three '/' in it ??
Printable View
In a textbox how do i test to see if it contains an '@' symbol '.com' and for a date to see if it has three '/' in it ??
Private Sub Command1_Click()
Dim myString As String
Dim myLen As Integer
Dim myAt As Boolean
Dim mySlash As Integer
Dim iCount As Integer
myAt = False
myString = Text1.Text
myLen = Len(myString)
For iCount = 1 To myLen
If Left(myString, 1) = "@" Then
myAt = True
End If
If Left(myString, 1) = "/" Then
mySlash = mySlash + 1
End If
myString = Right(myString, (myLen - iCount))
Next
If mySlash > 1 Then MsgBox "Yes, 2 or more / are involved."
If myAt = True Then MsgBox "Yes, there is an @ involved."
End Sub
Like is the fastest known operator!
Code:IF text1 like "*@*" then Msgbox "@ involved"
IF text1 like "*.com*" then Msgbox ".com involved"
Sorry i forgot the /'s well Hesaidjoe knows how to use instr, but this one will count them to 3, not 2 or more
Code:a=instr$(text1,"/")
Do while a
counter=counter+1
a=instr$(a+1,text1,"/")
loop
if counter=3 then msgbox "text1 has three / in it"
Thanks guys, just what i needed, i'll try the shorter method first !!!!!
I could count to 3 but I couldn't see where there are
3 {/} in a date expression..I assume looking for 3 was a typo
2000/07/02
therefore if it's > 1 the possibilities are it's correct.
assuming of course that the text1 text isn't something
like this
I came home/work and found my beer@mydesk/table was missing.
LOL
PS
I like the like (it works extremely well)
LOL
Sorry about that HeSaidJoe :)
if counter=2 ...
kedaman
not a problem.
Have a good one...gone out to enjoy the day!