Collabora Office 21.06 Help
傳回開啟檔案的大小,以位元組為單位。
Lof (FileNumber)
Long
FileNumber:任意數值型表示式,包含由 Open 陳述式指定的檔案編號。
若要獲取未開啟檔案的長度,請使用 FileLen 函式。
Sub ExampleRandomAccess
Dim iNumber As Integer
Dim sText As Variant REM 必須是變體型變數
Dim aFile As String
aFile = "c:\data.txt"
iNumber = Freefile
Open aFile For Random As #iNumber Len=32
Seek #iNumber,1 REM 起始位置
Put #iNumber,, "This is the first line of text" REM 用文字填入
Put #iNumber,, "This is the second line of text"
Put #iNumber,, "This is the third line of text"
Seek #iNumber,2
Get #iNumber,,sText
Print sText
Close #iNumber
iNumber = Freefile
Open aFile For Random As #iNumber Len=32
Get #iNumber,2,sText
Put #iNumber,,"This is a new line of text"
Get #iNumber,1,sText
Get #iNumber,2,sText
Put #iNumber,20,"This is the text in record 20"
Print Lof(#iNumber)
Close #iNumber
End Sub