Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Remove character up to specified character

Posted on 2006-11-06
5
Medium Priority
?
162 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
[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
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 2000 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 64

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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

618 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