Vb6 Performing an operation based on each line of a text file

I have a text file with a number of commands, each on a different line, what I need to do is go through the text file line by line and perform a set of operations for each line. How would I scroll line by line?

Example:

The text file contains:
johndoe.log
Apples and organics .log
monkies and zebras.log

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

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

and I know his oranges, sealed and went with him.

0


source to share


1 answer


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 watch FileSystemObject

+2


source







All Articles