Filesize




Public Function FormatFileSize(ByVal dblFileSize As Double) As String
Select Case dblFileSize
Case 0 To 999' Bytes
FormatFileSize = Format(dblFileSize) & " bytes"
Case 1000 To 1023999' KB
FormatFileSize = Format(dblFileSize / 1024, "##0.0") & " KB"
Case 1024000 To (1024 * 10 ^ 6) - 1 ' MB
FormatFileSize = Format(dblFileSize / (1024 ^ 2), "##0.0#") & " MB"
Case Is > (1024 * 10 ^ 6)
FormatFileSize = Format(dblFileSize / (1024 ^ 3), "##0.0#") & " GB"
End Select
End Function
'Assumes:Example:

"FormatFileSize(100)" will return "100 bytes"
"FormatFileSize(5500)" will return "5.4 KB"
"FormatFileSize(15000000)" will return "14.31 MB"










( filesize.html )- by Paolo Puglisi - Modifica del 17/12/2023