EOF Function

Description

Returns a value that indicates whether the end of a file has been reached.

Syntax

EOF(filenumber)

The filenumber argument is any valid file number.

Remarks

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.

See Also

Get Statement, Loc Function, LOF Function, Open Statement.

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.


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.