bytes to KB, MB or GB
with my code you can input a number of bytes and it will tell you how many Kilobytes Megabytes or Giga bytes it is equal to.
AI
AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.
Source Code
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
Upload
Original Comments (3)
Recovered from Wayback Machine