EOF Function


EOF Function

Class

Microsoft.VisualBasic.FileSystem

Syntax

     Dim result As Boolean = EOF(fileNumber) 


fileNumber (required; Integer)

Any valid file number of a file opened with FileOpen

Description

The EOF function indicates whether the current position within an open file is at the end of the file (true) or not (False). This function applies to files opened for binary, random, or sequential input.

Usage at a Glance

  • fileNumber must represent a file that is currently open.

  • If a file is opened for binary access, you cannot successfully use EOF with the Input procedure. Instead, use LOF and Loc. If you want to use EOF, you must use FileGet rather than Input. In this case, EOF returns False until the previous FileGet procedure is unable to read an entire record.

  • When appending data to files, the current file position will always be the end of the file, since the position marker is placed just after the most recently written data.

Example

     Dim oneLine As String     Dim fileID As Integer = FreeFile(  )     FileOpen(fileID, "c:\data.txt", OpenMode.Input, OpenAccess.Read)     Do While Not EOF(fileID)        oneLine = LineInput(fileID)        Console.WriteLine(oneLine)     Loop     FileClose(fileID) 

Version Differences

In Visual Basic 2005, the My.Computer.FileSystem object provides more robust access to file management features.

See Also

LOF Function




Visual Basic 2005(c) In a Nutshell
Visual Basic 2005 in a Nutshell (In a Nutshell (OReilly))
ISBN: 059610152X
EAN: 2147483647
Year: 2004
Pages: 712

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net