Siebel VB Language Reference > VB Language Reference >

Lof Function


This standard VB function returns the length in bytes of an open file.

Syntax

Lof(filenumber)

Argument
Description

filenumber

The number of the open file, as used in the Open statement

Returns

The length of the open file, in bytes.

Usage

The filenumber is the number used in the Open statement that opened the file.

Example

This example opens a file and prints its contents to the screen.

Sub Button_Click
   Dim fname As String,fchar() As String
   Dim x As Integer, msgtext As String, newline As String
   newline = Chr(10)
   fname = "d:\temp\trace.txt"
   On Error Resume Next
   Open fname for Input as #1
   If Err <> 0 then
      Exit Sub
   End If
   msgtext = "The contents of " & fname & " is: " _
      & newline & newline
   Redim fchar(Lof(1))
    For x = 1 to Lof(1)
       fchar(x) = Input(1,#1)
       msgtext = msgtext & fchar(x)
   Next x
      Close #1
End Sub

See Also

Eof Function
FileLen Function
Loc Function
Open Statement

Siebel VB Language Reference