Public Function ConvertBytes(ByVal Bytes As Long) As String
If Bytes >= 1073741824 Then
Return Format(Bytes / 1024 / 1024 / 1024, "#0.00") _
& " GB"
ElseIf Bytes >= 1048576 Then
Return Format(Bytes / 1024 / 1024, "#0.00") & " MB"
ElseIf Bytes >= 1024 Then
Return Format(Bytes / 1024, "#0.00") & " KB"
ElseIf Bytes > 0 And Bytes < 1024 Then
Return Fix(Bytes) & " Bytes"
Else
Return "0 Bytes"
End If
End Function
If Bytes >= 1073741824 Then
Return Format(Bytes / 1024 / 1024 / 1024, "#0.00") _
& " GB"
ElseIf Bytes >= 1048576 Then
Return Format(Bytes / 1024 / 1024, "#0.00") & " MB"
ElseIf Bytes >= 1024 Then
Return Format(Bytes / 1024, "#0.00") & " KB"
ElseIf Bytes > 0 And Bytes < 1024 Then
Return Fix(Bytes) & " Bytes"
Else
Return "0 Bytes"
End If
End Function
تعليقات
إرسال تعليق