Share via


FileSystem.EOF(Int32) 方法

定義

當已經到達為 True 或循序 Random 開啟的檔案之結尾時,傳回布林值 (Boolean) Input

public:
 static bool EOF(int FileNumber);
public static bool EOF (int FileNumber);
static member EOF : int -> bool
Public Function EOF (FileNumber As Integer) As Boolean

參數

FileNumber
Int32

必要。 包含任何有效檔案編號的 Integer

傳回

當已經到達為 True 或循序 Random 開啟的檔案之結尾時,為布林值 Input

例外狀況

檔案模式無效。

範例

這個範例會使用函 EOF 式來偵測檔案的結尾。 這個範例假設 Testfile 是包含數行文字的文字檔。

Dim TextLine As String
' Open file.
FileOpen(1, "TESTFILE", OpenMode.Input)
' Loop until end of file.
Do Until EOF(1)
    ' Read the line into a variable.
    TextLine = LineInput(1)
    ' Display the line in a message box.
    MsgBox(TextLine)
Loop
FileClose(1)

備註

使用 EOF 以避免嘗試取得超過檔案結尾的輸入所產生的錯誤。

EOF 式會傳 False 回 ,直到到達檔案結尾為止。 開啟或Binary存取的檔案Random時,EOF會傳回False直到上次執行的FileGet函式無法讀取整個記錄為止。

開啟檔案以供 Binary 存取時,嘗試使用 Input 函式讀取檔案,直到 EOF 傳回 True 時會產生錯誤。 LOF使用 與 Loc 函式來讀取二進位檔Input,或使用 EOF 函式時EOF使用 Get 。 開啟的 Output檔案時, EOF 一律會傳 True回 。

適用於

另請參閱