Siebel VB Language Reference > VB Language Reference >

Eof Function

This standard VB function is used to determine whether the end of an open file has been reached.





The file number used in the Open statement to open the file


The value -1 if the end of the specified open file has been reached, 0 otherwise.


For more information about assigning numbers to files when they are opened, read Open Statement.


This example uses the Eof function to read records from a Random file, using a Get statement. The Eof function keeps the Get statement from attempting to read beyond the end of the file. The subprogram, CreateFile, creates the file C:\TEMP001 used by the main subprogram. For another example, read FileDateTime Function.

(general) (declarations)
Option Explicit
Declare Sub CreateFile

Sub CreateFile
   ' Put the numbers 1-10 into a file
   Dim x as Integer
   Open "C:\TEMP001" for Output as #1
   For x = 1 to 10
      Write #1, x
   Next x
   Close #1
End Sub

Sub Button_Click
   Dim acctno
   Dim msgtext as String
   newline = Chr(10)
   Call CreateFile
   Open "C:\temp001" For Input As #1
   msgtext = "The account numbers are:" & newline
   Do While Not Eof(1)
         Input #1,acctno
         msgtext = msgtext & newline & acctno & newline
   Close #1
   Kill "C:\TEMP001"
End Sub

See Also

Get Statement
Input Function
Input Statement
Line Input Statement
Loc Function
Lof Function
Open Statement

Siebel VB Language Reference