Bytes Converter Function
A simple function that converts Bytes to GB, MB or KB.
Code Snippet:
Function SetBytes(Bytes,fKB)
if fKB=True then Bytes = Bytes * 1024
If Bytes >= 1073741824 Then
SetBytes = FormatNumber((Bytes / 1024 / 1024 / 1024),2,,-1,-1) & " GB"
ElseIf Bytes >= 1048576 Then
SetBytes = FormatNumber((Bytes / 1024 / 1024),2,,-1,-1) & " MB"
ElseIf Bytes >= 1024 Then
SetBytes = FormatNumber((Bytes / 1024),2,,-1,-1) & " KB"
ElseIf Bytes < 1024 Then
SetBytes = Bytes & " Bytes"
End If
End Function
If at first you fail, call it version 1.0
No comments:
Post a Comment