17-10-12, 12:33 AM
كاتب الموضوع : AhmedEssawy
مثال - SetBytes(74) 'returns "74 Bytes"
- SetBytes(5037) 'returns "4.92 KB"
- SetBytes(6383838) 'returns "6.09 MB"
- SetBytes(3368383278) 'returns "3.14 GB"
كود :
Function SetBytes(Bytes) As String
On Error GoTo hell
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
Exit Function
hell:
SetBytes = "0 Bytes"
End Function