Size to Bytes

Her en lille funktion der konvertere et tal til bytes, f.eks. bliver 12.500 til 12,2 Kbytes

Function getSize( size As Double ) As String
           Dim s As Double
           s = size
           Dim units As Variant
           units = Split( "bytes,Kb,Mb,Gb,Tb,Pb", "," )
           Dim i As Integer

           While s > 1024
                      s = s / 1024
                      i = i+1
           Wend

           getSize = Round( s, 1 ) & " " & units( i )
End Function