Check part of a string

Hi guys,

How can i check part of string, for example, If a field contained the value "Carrots", I want to say: If value contains "Carr" then it will find carrots.

Thanks.

Mari
mari_carmenAsked:
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.

VbmasterCommented:
Check out the helpfile for the 'Like' statement, for example you can use it like this..

boolean value = String Like "Carr*"   -> if String = "Carrots" this will return True
0
Erick37Commented:
Use InStr() function

Dim sString As String
sString = "Carrots"
If InStr(1, sString, "Carr", vbTextCompare) <> 0 Then
    'Found
Else
    'not found
End If
0

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
MirkwoodCommented:
I think this is what you mean

Private Sub Command1_Click()
    If (InStr(1, "carrots", "carr") > 0) Then
        MsgBox "Found"
    Else
        MsgBox "Not Found"
    End If
End Sub
0
Erick37Commented:
Mirkwood, please explain the difference.
0
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.