BTW, If the length of the MID function is not specified it will retrun th eremainder of the string.
It just finds the : moves 2 positions to the forst part of the filename and returns it.
Main Topics
Browse All TopicsHello Experts,
I have a report that is generated from a third party application as a text file. I need to read and obtain some specific information contained in this text file. I need the filenames that the report contains so that I can store in a variable to be used later in my application. Here is a sample report:
02/03/04 Report : BLB List Report 16:38:19
** Image library: 04034E02.BLB
23 documents of type BCKSCN
** Image library: 04034A08.BLB
82 documents of type 7070
The lines will always be in the same place and the files will always be in the same place. I know how to open a text file and read each line. What I don't know is how to take only the part of the line that I need. Here is my code:
If oFso.FileExists(App.path & "\blbreport.txt") Then
Set ts = fso.OpenTextFile(App.path & "\ blbreport.txt", 1, False)
While Not ts.AtEndOfStream
Line1 = ts.ReadLine
Line2 = ts.ReadLine
Line3 = ts.ReadLine
Line4 = ts.ReadLine
Line5 = ts.ReadLine
Line6 = ts.ReadLine
Line7 = ts.ReadLine
Wend
ts.Close
Set ts = Nothing
End If
Set fso = Nothing
I would like to clean the lines and just get the filenames.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Well I thought my update explained mid.
Here you go.
The Mid Funtion Takes this format Mid (String, StartPos, Length)
The Instr takes this format Instr(StartPos, String, String to find) and it returns the first position of the found string, 0 if failure)
So Mid(LineData, InStr(LineData, ":") + 2)
gives Mid(LineData, 17 + 2) ' 17 is the position of the : char we want to skip it and the space so add 2 that is the start positionj of the string to be returned
Since no length was specified it gets the rest. Mid(LineData, 19,8) would return the filename w/o the extension.
You need to put it in a function like this....
Function ParseFileName (LineData As String) As String
ParseFileName=""
If InStr(LineDate,":") Then ParseFileName=Mid(LineData
End Function
Then just pass it each line read from the report.
Business Accounts
Answer for Membership
by: HoweverCommaPosted on 2004-12-20 at 19:27:35ID: 12872831
LineData = "** Image library: 04034E02.BLB"
FileName = Mid(LineData, InStr(LineData, ":") + 2)
MsgBox (FileName)