Link to home
Start Free TrialLog in
Avatar of n96radsb
n96radsb

asked on

search for a string in an array

I have an array of strings
now I want to search  the array for a specific string or a part of a string. I just want to know where in the array the string is.

thanks in advance
ASKER CERTIFIED SOLUTION
Avatar of JR2003
JR2003

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
Avatar of rajaloysious
rajaloysious

     Dim listItems(4) As String
      Dim searchstr As String
      Dim bFound As Boolean
     
      searchstr = "Fou"
      Dim anItem As Variant
      listItems = Array("One", "Two", _
         "Three", "Four", "Five")
      List1.Clear
      bFound = False
      For Each anItem In listItems
         If InStr(1, anItem, searchstr) Then
            bFound = True
            Exit For
         End If
         bFound = False
      Next
    If bFound Then
        MsgBox "Found"
    Else
        MsgBox " Not found"
    End If