by Denis Petrusenko (6 Submissions)
Category: String Manipulation
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Sat 3rd August 2002
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Windows File Size Formatting
API Declarations
'
' Basically, it returns the size nicely formatted, like Windows inFile Properties.
Dim R As String
If s <= (2 ^ 10) Then R = s & " Bytes"
If s > (2 ^ 10) And s <= (2 ^ 20) Then R = Round(s / (2 ^ 10), 2) & " KB"
If s > (2 ^ 20) And s <= (2 ^ 30) Then R = Round(s / (2 ^ 20), 2) & " MB"
If s > (2 ^ 30) And s <= (2 ^ 40) Then R = Round(s / (2 ^ 30), 2) & " GB"
If s > (2 ^ 40) And s <= (2 ^ 50) Then R = Round(s / (2 ^ 40), 2) & " TB"
If s > (2 ^ 50) And s <= (2 ^ 60) Then R = Round(s / (2 ^ 50), 2) & " PB"
ProperSize = R
End Function