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
????Close
????Open "test.dat" For Random Access Read Write Shared As #1
????r% = Lof(1)
????Close
????MsgBox "The length of 'test.dat' is: " & r%
End Sub
|