FileSystem.EOF(Int32) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
當開啟檔案的結尾RandomInput或連續檔案結束時,會回傳一個布林值True。
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一個包含任何有效檔案號的 THAT。
傳回
當開啟檔案RandomInput的末尾或連續檔案時,會顯示布林值True。
例外狀況
檔案模式無效。
範例
此範例使用 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直到檔案結束。 當檔案開啟或存取時RandomBinary,會EOF回傳False,直到最後執行FileGet的函式無法讀取整個記錄為止。
當檔案開啟存取 Binary 時,嘗試使用 Input 直到 EOF 返回 True 函式讀取檔案會產生錯誤。 讀取帶有 的二進位檔案時,請使用 LOF and Loc 函數,或EOF在使用EOF函式時使用 Get 。Input 當檔案開啟於 Output時, EOF 總是返回 True。