Función Eof
Determina se o apuntador de ficheiro chegou ao final do ficheiro.
Sintaxe:
Eof (ExpresiónEnteiro As Integer)
Valor de retorno:
Bool
Parámetros:
Intexpression: Any integer expression that evaluates to the number of an open file.
EOF utilízase para evitar erros ao tentar obter datos despois do final dun ficheiro. Cando usa a instrución Input ou Get para ler dun ficheiro, o apuntador do ficheiro avanza de acordo co número de bytes lidos. Cando chega ao final do ficheiro, EOF devolve o valor "True" (-1).
Exemplo:
Sub ExampleWorkWithAFile
Dim iNumber As Integer
Dim sLine As String
Dim aFile As String
Dim sMsg As String
aFile = "c:\data.txt"
iNumber = Freefile
Open aFile For Output As #iNumber
Print #iNumber, "First line of text"
Print #iNumber, "Another line of text"
Close #iNumber
iNumber = Freefile
Open aFile For Input As iNumber
While Not eof(iNumber)
Line Input #iNumber, sLine
If sLine <>"" Then
sMsg = sMsg & sLine & chr(13)
End If
Wend
Close #iNumber
MsgBox sMsg
End Sub