August 2001
Intermediate to advanced
656 pages
18h 5m
English
LOF Function
Microsoft.VisualBasic.FileSystem
LOF(filenumber)filenumber
Use: Required
Data Type: Integer
Any valid file number
Long Integer
Returns the size of an open file in bytes
filenumber must be the number of a file
opened using the FileOpenfunction.
The following example shows how to use the LOF
function to prevent reading past the end of a file in binary mode:
Dim fr As Integer = FreeFile( )
Dim sChar As Char
FileOpen(fr, "c:\data.txt", OpenMode.Binary, OpenAccess.Read)
Do While Loc(fr) < LOF(fr)
FileGet(fr, sChar)
Debug.Write(Loc(fr) & ": ")
Debug.WriteLine(sChar)
Loop
LOF works only on an open file; if you need to
know the size of a file that isn’t open, use the
FileLen function.
Read now
Unlock full access