CitectVBA Programming Reference > CitectVBA Function Reference > File I/O Functions > LOF


LOF function returns a number indicating the byte length of a sequential file opened using the Open statement.

The required FileNum argument must contain an Integer representing any valid number associated with an open file.

Note: The file system keeps track of all open files and the current position of access within every file. Every statement or function that accesses the data within a file, alters the current position within that file. The Loc function can be used to determine the current position within an open file.

The LOF function returns the size of a file that is already open.
To obtain the length of a file that is not open, use the FileLen function.

Use the LOF and Loc functions instead of EOF when reading binary files with the Input function.




An Integer or numeric expression representing any valid number in the range 1 to 511 inclusive, which is referenced by the file system to be associated with an open file.

Return Value

Returns a Long representing the size of a file in bytes.

Related Functions

EOF | FileLen | Loc | Seek


Dim lonFileSize As Long
lonFileSize = LOF "C:\TESTFILE.txt" ' returns length of file in bytes