by Alex Rohr (2 Submissions)
Category: Files/File Controls/Input/Output
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Mon 14th June 1999
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Convert Bytes into K or MB
API Declarations
Dim FileSize2 As String
' convert the current file size to different format
Static xx
FileSize1 = FileLen(File1.Path & "\" & File1.List(0))
xx = FileSize1 / 1024
If Len(FileSize1) >= 7 Then
FileSize2 = Format((xx / 1024), "0.00")
FileSize2 = FileSize2 & " MB"
ElseIf Len(FileSize1) >= 4 Then
xx = Format((FileSize1 / 1024), "0.00")
FileSize2 = xx & " K"
Else
FileSize2 = FileSize1 & " Bytes"
End If
Debug.Print "File: " & File1.List(0) & vbCrLf & "Old Size: "; FileSize1 & _
vbCrLf & "New Size: " & FileSize2
Me.Caption = File1.List(0) & " - Size: " & FileSize2
End Function