P
Phil Hibbs
This is the example code in the help file:
Dim InputData
Open "MYFILE" For Input As #1 ' Open file for input.
Do While Not EOF(1) ' Check for end of file.
Line Input #1, InputData ' Read line of data.
Debug.Print InputData ' Print to the Immediate window.
Loop
Close #1 ' Close file.
In most other languages, the EOF only gets set when you have attempted
to read past the end of a file. So, if the file is empty, this code
would read a blank line and then attempt to print it. In Excel, does
EOF get set right at the start and the loop do nothing? If there is
exactly one line of data, does EOF get set after the first Line Input
command? That is what appears to be happening.
Phil Hibbs.
Dim InputData
Open "MYFILE" For Input As #1 ' Open file for input.
Do While Not EOF(1) ' Check for end of file.
Line Input #1, InputData ' Read line of data.
Debug.Print InputData ' Print to the Immediate window.
Loop
Close #1 ' Close file.
In most other languages, the EOF only gets set when you have attempted
to read past the end of a file. So, if the file is empty, this code
would read a blank line and then attempt to print it. In Excel, does
EOF get set right at the start and the loop do nothing? If there is
exactly one line of data, does EOF get set after the first Line Input
command? That is what appears to be happening.
Phil Hibbs.