Solved

how to find the end of the string occurance

Posted on 2007-11-23
4
203 Views
Last Modified: 2010-04-23
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
0
Comment
Question by:dchau12
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 20340991
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
 

Author Comment

by:dchau12
ID: 20341020
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
 

Author Comment

by:dchau12
ID: 20341151
good enough.  Thanks Angell.
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 20341946
>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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question