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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to parse everything to the left of "_"

Status
Not open for further replies.

cyberbob2

Programmer
Nov 13, 2003
32
US
Hi all,

I have a string, "1234_testfile.doc". Can someone please show me how to parse out everything to the left of the "_"? This number will grow so this would be the best solution.

Thanks in advance,
KP
 
Couple different ways to do this. One is to use Left and InStr to get the value, and the other is to Split:

Code:
Dim filevalue

filevalue = Left(filename, InStr(filename, "_") + 1)
and
Code:
Dim filevalue

filevalue = Split(filename, "_")(0)

Lee
 
My first suggestion has an error in it. The plus sign (+) should be a minus sign (-).

Lee
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top