This documentation is archived and is not being maintained.

LOF Function

Returns a Long representing the size, in bytes, of a file opened using the FileOpen function.

Public Function LOF(ByVal FileNumber As Integer) As Long

Parameter

FileNumber
Required. An Integer containing a valid file number.

Exceptions/Errors

Exception type Error number Condition
IOException 52 FileNumber does not exist.
IOException 54 File mode is invalid.

Remarks

Use the FileLen function to obtain the length of a file that is not open.

Example

This example uses the LOF function to determine the size of an open file. This example assumes that TESTFILE is a text file containing sample data.

Dim length As Integer
FileOpen(1, "C:\TESTFILE.TXT", OpenMode.Input) ' Open file.
length = LOF(1)   ' Get length of file.
Debug.WriteLine(length)
FileClose(1)   ' Close file.

Smart Device Developer Notes

This function is not supported.

Requirements

Namespace: Microsoft.VisualBasic

Module: FileSystem

Assembly: Microsoft Visual Basic .NET Runtime (in Microsoft.VisualBasic.dll)

See Also

EOF Function | FileLen Function | Loc Function | FileOpen Function | IOException Class

Show: