Using the "Like" function

I want to search a string for the presence of another string.
SearchFor = "the"
I want to have the result work if the string contains exactly "the" if the characters are either upper case or lower case.
string Like (     )
I need the syntax in the (   ).
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

The InStr function can search for the presence of one string in a larger string.

InStr(1,"asasfthe","the",vbTextCompare) will return 6, indication "the" begins at position 6.

The first parameter is the starting position to begin searching

The second param is the string to search

The third param is what you are searching for.

The last param is an optional one.  In the above example, search ignore case.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Using the Like operator:

Dim str As String
str = "seArchThEstring"
If LCase(str) Like "*the*" Then
    Debug.Print "Found it!"
    Debug.Print "Not found"
End If
Private Sub Form_Click()
    Dim str As String
    str = "seArchThEstring"
    If str Like "*[tT][hH][eE]*" Then
        Caption = "Found it!"
        Caption = "Not found"
    End If
End Sub
Lee5Author Commented:
Thanks for the more usable approach

Erick37 is also a good answer, but needs some UCase stuff.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.