EOF function
Summary
End-of-file state for open file.
Syntax
EOF(filenumber)
The required filenumber argument is an Integer containing any valid file number.
Example
Example
This example uses the EOF function to detect the end of a file. This example assumes that MYFILE is a text file with a few lines of text.
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.
This example uses the EOF function to detect the end of a file. This example assumes that MYFILE is a text file with a few lines of text.
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.