Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help finding part of a String 1

Status
Not open for further replies.

teach314

Technical User
Jul 29, 2011
183
0
0
CA
hi - given a string (strResult), I need to return the part of the string after the 2nd underscore from the left.
So, from "TEST_88a_16", I need to return "16". From "TEST_45_CHK_56a", I need to return "CHK_56a".

I'm just not sure how to reference the 2nd underscore.

thanks - any clues are appreciated.

 
A general approach could be (untested)

-confirm that an underscore exists and get its position
Instr(strResult,"_") will return a number 0 if not found, or integer representing position in strResult

To get second "_", retest strResult looking from position of first "_" +1 to the end
PositionOfSecondUnderscore = Instr( Instr(strResult,"_") +1,strResult,"_")

see
 
thanks jedraw! I hadn't thought of using an InStr function as the optional 1st argument of another InStr function. This works very well.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top