how to find the end of the string occurance

I can find the beginnning of the string occurance with the indexof function.  How do I find the end of the string occurance?

       If localUnParsedAddress.Contains(" Drive ") Then
           'This gives me the beginning of the string occurance.  Need the end
            x = localUnParsedAddress.IndexOf(" Drive ")
            EndOfOccurance = ???
       End If
dchau12Asked:
Who is Participating?
 
Guy Hengel [angelIII / a3]Connect With a Mentor Billing EngineerCommented:
you mean, the end of the string you are looking for?

 Dim search_for as string = " Drive "

If localUnParsedAddress.Contains(search_for) Then
           'This gives me the beginning of the string occurance.  Need the end
            x = localUnParsedAddress.IndexOf(search_for)
            EndOfOccurance = x + search_for.Length
       End If
0
 
dchau12Author Commented:
That works if I know that drive is what I am searching for.   I need to search for a lot of different string though.  How would you programatically do something like this?

If localUnParsedAddress.Contains(" Drive ") or localUnParsedAddress.Contains(" Lane ") or localUnParsedAddress.Contains(" Street ") Then
           'This gives me the beginning of the string occurance.  Need the end
            x = localUnParsedAddress.IndexOf(" Whatever string it contains ")
            EndOfOccurance = ???
       End If

0
 
dchau12Author Commented:
good enough.  Thanks Angell.
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
>I need to search for a lot of different string though.
you can put the searchable items into an array, and loop the array...
0
All Courses

From novice to tech pro — start learning today.