Solved

Remove character up to specified character

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

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

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…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

695 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