Use EOF to avoid the error generated by attempting to get input past the end of a file.
The EOF function returns False until the end of the file has been reached. With files opened for Random or Binary access, EOF returns False until the last executed FileGet function is unable to read a whole record.
With files opened for Binary access, an attempt to read through the file using the Input function until EOF returns True generates an error. Use the LOF and Loc functions instead of EOF when reading binary files with Input, or use Get when using the EOF function. With files opened for Output, EOF always returns True.
Dim TextLine AsString' Open file.
FileOpen(1, "TESTFILE", OpenMode.Input)
' Loop until end of file. DoUntil EOF(1)
' Read the line into a variable.
TextLine = LineInput(1)
' Display the line in a message box.
Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)