cs_JMO
Messages postés1854Date d'inscriptionjeudi 23 mai 2002StatutMembreDernière intervention24 juin 2018
-
4 avril 2006 à 21:30
cs_JMO
Messages postés1854Date d'inscriptionjeudi 23 mai 2002StatutMembreDernière intervention24 juin 2018
-
4 avril 2006 à 22:31
Bonsoir à tous....
En vbs, j'ai un petit problème pour arrondir un chiffre.
J'ai beau essayé avec Round, CInt, Fix...je n'y arrive pas..pourtant ça parait simple.
J'ai un chiffre "23 456 789" (Koctets) et ma question comment l'arrondir pour avoir
"23 457" (Mo), tout en conservant les espaces (FormatNumber)
Avec ma synthaxe erronée, j'obtiens "23457".
Ci-dessous, mon code complet et en rouge, où je coince.
Ce script analyse la volumétrie des disks fixes.
Merci d'avance,
jean-marc
Call ShowFreePourcent()
MsgBox ShowFreePourcent
Function ShowFreePourcent()
Dim fso, d, s
Set fso = CreateObject("Scripting.FileSystemObject")
Set dc = fso.Drives 'permet de parcourir tous les disks
For Each d in dc
Select Case d.DriveType 'selection en fonction du type de lecteur
' Case 0: s = "Inconnu"
' Case 1: s = " Disk Amovible"' Case 2: s " Disk Fixe" & "> Espace disponible: " & d.AvailableSpace/1024 & " Koctets"
' Case 3: s = " Lecteur Réseau"
' Case 4: s = " Lecteur CD-ROM"
' Case 5: s = " Disk virtuel"
Case 2:
s = "Lecteur " & d.DriveLetter & ":"
s = s & vbCrLf
s = s & "Taille totale : " & FormatNumber(d.TotalSize/1024, 0) & " KOctets" & vbCrLf
s = s & "Taille occupée : " & FormatNumber(FormatNumber(d.TotalSize/1024, 0) - _
FormatNumber(d.AvailableSpace/1024, 0), 0) & " KOctets" & vbCrLf
s = s & "Taille disponible : " & FormatNumber(d.AvailableSpace/1024, 0) & " KOctets" & vbCrLf
s = s & "Pourcentage occupé : " & FormatPercent((FormatNumber(d.TotalSize/1024, 0) -_
FormatNumber(d.AvailableSpace/1024, 0)) / FormatNumber(d.TotalSize/1024, 0)) & vbCrLf
s = s & "Pourcentage libre : " & FormatPercent(FormatNumber(d.AvailableSpace/1024, 0) /_
FormatNumber(d.TotalSize/1024, 0)) & vbCrLf&vbCrLf&_
"taille totale en Mo: " & CInt(FormatNumber(FormatNumber(d.TotalSize/1024, 0) / 1000)) & " Mo"
result = result &vbCrLf& s &vbCrLf
Case Else
End Select
Next
ShowFreePourcent = result
End Function