Link to home
Start Free TrialLog in
Avatar of sirimit
sirimit

asked on

What simple function for find word in my string ? Thank you.

What simple function for find word in my string ?

Ex. Dim tmpString As String = "View sample of a well-asked Question"

I want to check "sample" into variable tmpString is return true. I want simple function. Thank you.

ps. vb style thank.
Avatar of Dirk Haest
Dirk Haest
Flag of Belgium image

Very easy function

Call:
dim myBool as boolean
myBool = CheckField(tmpString, "sample")
    Public Function CheckField(ByVal strSentence As String, ByVal strWord As String) As Boolean
        If strSentence.IndexOf(strWord) > 0 Then
            Return True
        Else
            Return False
        End If
    End Function

Open in new window

If tmpString.IndexOf("Sample",1)>0 then
msgbox "String Exist..!"
else
msgbox "not present..!!"
end if
ASKER CERTIFIED SOLUTION
Avatar of Joel Coehoorn
Joel Coehoorn
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial