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

Find specific text in a file

Status
Not open for further replies.

testare

Programmer
Jan 21, 2005
127
I have 3000 files that i would like to get a specific text.
It is always at the second line of the files.
The textfiles are always something like this.

01,04,01,00012, 2005-07-25 11:40:08, 2005-07-25 21:02:00, 0
02,100,111,"2",112,"2",113,"60064","2005-07-25"

I would like to capure the text where i marked it as bold.

I would like to use this.
gmmastros helped me with for each and i like to continue using it.

Code:
Dim fso As FileSystemObject 
Dim oFolder As Scripting.Folder 
Dim oFile As Scripting.File 
Dim strData As String 

For Each oFile In oFolder.Files 
    strData = oFile.OpenAsTextStream(ForReading).ReadAll 
Next

How can i capture the bold text for every file that i have.
The text that i would like to capture is always after the seventh comma (,)
 
Dim fso As FileSystemObject
Dim oFolder As Scripting.Folder
Dim oFile As Scripting.File
Dim strData As String

[red]Dim MyData As String[/red]

For Each oFile In oFolder.Files
strData = oFile.OpenAsTextStream(ForReading).ReadAll

[red]myData = Split(Split(strData, vbCrLf)(1), ",")(7)[/red]
Next



-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
strWhatYouWant = Split(Split(strData, vbCrLf)(1), ",")(7)


Untested but should get you started.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
I type too slow. :)

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
But I like the way you think. [wink]

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
I've tested it and it works exactly how i wanted it to work.

Hi gmmastros
I really appriciate that help u gave med last time with for each it has been very useful.

 
No problem. I'm glad to help.

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top