Solved

Remove character up to specified character

Posted on 2006-11-06
5
155 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

706 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

20 Experts available now in Live!

Get 1:1 Help Now