Solved

Remove character up to specified character

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

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

830 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