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

stripping string

Status
Not open for further replies.

zzzzzeke

Programmer
Mar 1, 2004
14
US
i have a string like:

\\folder\folder\folder\folder\folder\folder\210000\213790\file911723v.jpg

i would like to strip it down to return just 911723.

would my best be using the REPLACE function?

Thanks in advance
 
If you know that the file names will always look like that, the easiest way I can think of would be:
Code:
Mid(yourString, InStrRev(yourString, "/") + 5, 6)
The InstrRev starts at the end of the string and looks backwards through it for the slash, and returns a number of the first match. We add 5 to that (f i l e number) and then use Mid to take that character and the next 6.
 
thanks for the reply....i ended up using the replace function because the folder path is generated dynamically

Code:
objFile = replace(objFile, "v.jpg", "")	objFile = replace(objFile, objFolder & "\file", "")
 
The method I suggested doesn't care about the folder path, btw, because it's looking from the right. The path could be anything. Mine should operate faster than yours, but not enough that it probably matters unless you're doing it repeatedly.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top