Public Enum BYTEVALUES
KiloByte = 1024 MegaByte = 1048576 GigaByte = 107374182 End Enum Public Function CutDecimal(Number As String, ByPlace As Byte) As String Dim Dec As Byte Dec = InStr(1, Number, ".", vbBinaryCompare) ' find the Decimal If Dec = 0 Then CutDecimal = Number 'if there is no decimal Then dont do anything Exit Function End If CutDecimal = Mid(Number, 1, Dec + ByPlace) 'How many places you want after the decimal point End Function Function GiveByteValues(Bytes As Double) As String If Bytes < BYTEVALUES.KiloByte Then GiveByteValues = Bytes & " Bytes" ElseIf Bytes >= BYTEVALUES.GigaByte Then GiveByteValues = CutDecimal(Bytes / BYTEVALUES.GigaByte, 2) & " Gigabytes" ElseIf Bytes >= BYTEVALUES.MegaByte Then GiveByteValues = CutDecimal(Bytes / BYTEVALUES.MegaByte, 2) & " Megabytes" ElseIf Bytes >= BYTEVALUES.KiloByte Then GiveByteValues = CutDecimal(Bytes / BYTEVALUES.KiloByte, 2) & " Kilobytes" End If End Function |