See Also Example
Returns a Long integer that indicates the length of a file in bytes.
Syntax
FileLen (filename)
Remarks
The argument filename can be any string expression The file specification may include optional drive and path information.
If the specified file is open when the FileLen function is called, the value returned represents the length of the file before it was opened.
FileDateTime Function
GetAttr Function
LOF Function
The example uses FileLen to get file size information about a file. File size information is displayed in a message box anytime you choose the name of a file in the file list box. To try this example, paste the code into the Declarations section of a form containing a file list box named File1. Then press F5 to start.
Sub File1_Click ()
Dim Msg, TimeStamp ' Declare variables.
FName = File1.FileName ' Get selected file name.
TimeStamp = FileDateTime(FName) ' Get file date/time info.
Msg = UCase(FName) & " was created or last modified on "
Msg = Msg & Format(TimeStamp, "dddddd") & " at "
Msg = Msg & Format(TimeStamp, "h:mm AM/PM") & ". Its size is "
Msg = Msg & FileLen(FName) & " bytes." ' Get file size.
MsgBox Msg ' Display message.
End Sub