Lof (function)




Returns a Long representing the number of bytes in the given file.


The filenumber parameter is an Integer used by the Basic Control Engine to refer to the open file, the number passed to the Open statement.

The file must currently be open.


This example creates a test file, writes ten records into it, then finds the length of the file and displays it in a message box.

Const crlf = Chr$(13) + Chr$(10)

Sub Main()
  a$ = "This is record number: "

  Open "test.dat" For Random Access Write Shared As #1
  msg1 = ""
  For x = 1 To 10
    rec$ = a$ & x
    put #1,,rec$
    msg1 = msg1 & rec$ & crlf
  Next x

  Open "test.dat" For Random Access Read Write Shared As #1
  r% = Lof(1)
  MsgBox "The length of 'test.dat' is: " & r%
End Sub

See Also

Loc (function); Open (statement); FileLen (function).

More information