views:

382

answers:

1

I have a text file with a series of commands each one is on a diferent line what I need to do is go through the text file line by line and for each line perform a set of operations. How would I loop through line by line?

Example:

Text file contains:
johndoe.log
Apples and organes.log
monkies and zebras.log

script would grab line 1(johndoe.log)
create a new text file named johndoe.log
go to line two
create a new text file named apples and organes.log
etc... until the text file is complete

I know how to do everything except the loop that performs an operation on each line of the text file :(

and I know its oranges, typoed and went with it.

+2  A: 

In classic VB6:

Dim LineData as String
Dim FileHandle as Integer

FileHandle = FreeFile
Open "C:\Test.txt" For Input As #FileHandle
Do While Not EOF(FileHandle)
    Line Input #FileHandle, LineData
    ' Do whatever with LineData
Loop
Close #FileHandle

Or you can look at the FileSystemObject

Cade Roux
I'm suddenly reliving my nightmares of eight years ago ... I'd managed to forget about the file handle syntax ... (Or maybe block it out?) FileSystemObject was SUCH an improvement!
John Rudy