Solved

Strip string after a specific character in VB.net

Posted on 2008-10-18
2
831 Views
Last Modified: 2010-04-21
Dear Experts,

How can I extract the text 'The cat sat on the>' from the string:

string = "The cat sat on the>mat"

I want to strip out everything after the '>' character (escape character in my script)

Any help would be appreciated,

Thanks

Nick
0
Comment
Question by:nkewney
2 Comments
 
LVL 47

Accepted Solution

by:
Wayne Taylor (webtubbs) earned 500 total points
ID: 22747655
Use the String.SubString and String.indexOf methods....

    Dim s As String = "The cat sat on the>mat"
    Dim NewStr As String = s.Substring(0, s.IndexOf(">") + 1)

Wayne
0
 
LVL 1

Author Closing Comment

by:nkewney
ID: 31507393
Great, thanks :)
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

808 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