Solved

Remove character up to specified character

Posted on 2006-11-06
5
156 Views
Last Modified: 2010-04-23
I have a variable that carries the value

iTopicID = a0_26

What I need to do is remove a0_ so I only have the 26 assigned to iTopicID.

Can anyone help? Thanks
0
Comment
Question by:wilcor14
5 Comments
 
LVL 17

Expert Comment

by:ZeonFlash
ID: 17883834
Here are several different ways.

Dim iTopicID As String = "a0_26"

'Remove the first 3 characters
iTopicID = iTopicID.Remove(0, 3)

'Or Trim the first 3 characters
iTopicID = iTopicID.TrimStart("a0_")

'Or Replace a0_ with nothing
iTopicID = iTopicID.Replace("a0_", "")

'Or Get only the characters after a0_
iTopicID = iTopicID.Substring(3, iTopicID.Length - 1)
0
 
LVL 29

Accepted Solution

by:
Nightman earned 500 total points
ID: 17883843
iTopicID=iTopicID.Substring(InStr(iTopicID, "_"))
0
 

Author Comment

by:wilcor14
ID: 17883866
There could be a possibility of there being more than 3 characters at the beginning of the string. The consistent character is the _ which I was hoping there was a procedure of selecting the remaining characters after this _ character.

Sorry, I should have clarified that before hand.
Thanks
0
 
LVL 29

Expert Comment

by:Nightman
ID: 17883888
If there is always only 1 underscore character, my solution will do the job perfectly.
0
 
LVL 62

Expert Comment

by:Fernando Soto
ID: 17884170
Hi wilcor14;

This will do what you want.

        iTopicID = iTopicID.Substring(iTopicID.LastIndexOf("_"c) + 1)

Fernando
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Vb.Net Date Formatting Assistance 4 36
fso.FolderExists("\\server\HiddenFolder$") 4 52
Allow User To Arrange Columns At Datagridview 3 19
Help with Syntax 9 29
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

863 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now