Link to home
Start Free TrialLog in
Avatar of jazzIIIlove
jazzIIIloveFlag for Sweden

asked on

round is not working for Cstr in VBS

Hi;

Following vbs snippet is not working which I want to round a file size:

 strWrite.WriteLine(oF.Name + "," + CStr(Round(oF.Size/1048576),2) + "," + CStr(oF.Files.Count) + "," + CStr(oF.Subfolders.Count))

Open in new window


whereas this is working which is not rounded:

 strWrite.WriteLine(oF.Name + "," + CStr(oF.Size/1048576) + "," + CStr(oF.Files.Count) + "," + CStr(oF.Subfolders.Count))

Open in new window


And I want to round the value. What to do?

Regards.
Avatar of Joe Howard
Joe Howard
Flag of United States of America image

Try this:
 strWrite.WriteLine(oF.Name & "," & CStr(Round(oF.Size/1048576),2) & "," & CStr(oF.Files.Count) & "," & CStr(oF.Subfolders.Count))

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Robert Schutt
Robert Schutt
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jazzIIIlove

ASKER

First one failed, second one worked