VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Windows File Size Formatting

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.

Rate Windows File Size Formatting




 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

Download this snippet    Add to My Saved Code

Windows File Size Formatting Comments

No comments have been posted about Windows File Size Formatting. Why not be the first to post a comment about Windows File Size Formatting.

Post your comment

Subject:
Message:
0/1000 characters