Returns a value that indicates whether the end of a file has been reached.
EOF(filenumber)
The filenumber argument is any valid file number.
Use EOF to avoid the error generated by the attempt to get input past the end of a file.
The EOF function returns False unless the end of the file has been reached; then it returns True. When used with files opened for Random or Binary access, EOF returns False unless the last executed Get statement is unable to read an entire record; then it returns True.
Get Statement, Loc Function, LOF Function, Open Statement.
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.
Open "MYFILE" For Input As #1 ' Open file for input.While Not EOF(1) ' Check for end of file. Line Input #1, InputData ' Read line of data. Debug.Print InputData ' Print to Debug window.#1 ' Close file.