تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
تحويل التنسيق بايت الي Kb- Mb- Gb بالكود
#1
كاتب الموضوع : 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
}}}
تم الشكر بواسطة:



التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم