Function BytesToMegabytes(ByVal Bytes As String) As String
Dim SetBytes As String
SetBytes = ""
If Bytes >= 1073741824 Then
SetBytes = Format(Bytes / 1024 / 1024 / 1024, "#0.00") _
& " GB"
ElseIf Bytes >= 1048576 Then
SetBytes = Format(Bytes / 1024 / 1024, "#0.00") & " MB"
ElseIf Bytes >= 1024 Then
SetBytes = Format(Bytes / 1024, "#0.00") & " KB"
ElseIf Bytes < 1024 Then
SetBytes = Fix(Bytes) & " Bytes"
End If
Return SetBytes
End Function
Private Function BytesToMegabytes(ByVal Bytes As Long) As Long
Dim dblAns As Double
dblAns = (Bytes / 1024) / 1024
BytesToMegabytes = Format(dblAns, "###,###,##0.00")
End Function
Originally Posted on December 14, 2013
Last Updated on October 26, 2015
Last Updated on October 26, 2015
All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.