Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checking string on characters

Status
Not open for further replies.

BaDi

Programmer
May 14, 2002
32
0
0
NL
Hi!

I have a string and I would like to check if the string contains a specific word so I can filter the string out if it contains the specific word.

Thanx in advance!
 
you can use the InStr function.
here's an example.

Code:
Option Explicit

Private Sub Command1_Click()
  Dim StringToCheck As String
  Dim SpecificWord As String
  
  StringToCheck = "the quick brown fox"
  SpecificWord = "FOX"
  
  If InStr(1, StringToCheck, SpecificWord, vbTextCompare) Then
    MsgBox "Found '" & SpecificWord & "' in '" & StringToCheck & "'"
  Else
    MsgBox "Did not find '" & SpecificWord & "' in '" & StringToCheck & "'"
  End If
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top