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

Parsing out a section of a text file line.

Status
Not open for further replies.

gjsala

Technical User
Feb 20, 2003
107
US
Thanks for your help in advance. I have a line in a text file for example: c:\program\Files\122310.xlm
I would like to capture the 122310.xml in the text file. The only catch this section will change from one text file to another for example now its 122310.xlm the next text file it could change to 92310.xml and as you can see the number of characters is different. Any help would be appreciated.

Thanks!
 
strLine = "c:\program\Files\122310.xlm"
MsgBox Mid(strLine, 1 + InStrRev(strLine, "\"))

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
You seem to be referring to the "file name" although you're using the term, "text file". If I'm right, I think your best approach would be with instr.

Let's say you have a string, strFN, that has the value, c:\program\Files\122310.xlm.
Code:
i=instr(1,strFN,"\")
do while i>-1
  strFN=mid(strFN,i)
  i=instr(1,strFN,"\")
loop

_________________
Bob Rashkin
 
Ah, instrrev. I didn't know about that one.

_________________
Bob Rashkin
 
Thank you for the quick response! In my request c:\program\Files\122310.xlm this will be listed in the text file not the name of the text file. I'm looking to capture the 122310.xml but this 122310.xml will change and not have the same number of characters.

Thanks!
 


I'm looking to capture the 122310.xml but this 122310.xml will change and not have the same number of characters.
Code:
MsgBox Split("c:\program\Files\122310.xlm","\")(UBound(Split("c:\program\Files\122310.xlm","\")))


Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Thank you all for your help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top