26-07-17, 03:23 PM
27-07-17, 08:15 AM
أهلا أخي الكريم , إستخدم هذا الكود :
PHP كود :
Private Function SetBytes(Bytes) As String
On Error GoTo zErr
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
zErr:
SetBytes = "0 Bytes"
End Function
Private Sub Command1_Click()
Dim FSO As Object
Dim Folder As Object
Set FSO = CreateObject("Scripting.FileSystemObject")
If FSO.FolderExists("C:\Program Files") Then
Set Folder = FSO.GetFolder("C:\Program Files")
MsgBox SetBytes(Folder.Size)
End If
Set Folder = Nothing
Set FSO = Nothing
End Sub