Re: Memory output format



FormatNumber is a function, but you have used it as sub. Try:

For Each objItem in colItems
strTotalPhysicalMemory = objItem.TotalPhysicalMemory
WScript.Echo FormatNumber(strTotalPhysicalMemory, 0)
Next

--
Richard
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net

"Rick" <drummer10980@xxxxxxxxx> wrote in message
news:1165343414.537645.133610@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Richard,
thanks for the response, I'm new at this and apprieciate the help. I am
using the following inside a script when I run the formatnumber with
parentheses I get the following error.

Cannot use parentheses when calling a Sub

I take out the parentheses, the script runs but does not format the
number. what could I look at?

Rick

Set colItems = objWMIService.ExecQuery("Select * from
Win32_ComputerSystem",,48)
For Each objItem in colItems


strTotalPhysicalMemory = objItem.TotalPhysicalMemory
FormatNumber strTotalPhysicalMemory
WScript.Echo strTotalPhysicalMemory
Richard Mueller wrote:
Rick wrote:

I'm trying to format a string in a VB Script for amount of memory I am
getting from a server. the string is 1073197056, I need to have it show
as a readable number, say 1 gig, I also will have the problem for
systems with 512 and 2 gig etc. Is there a conversion I can do on these
numbers

You can display the number with commas, which makes it much easier to
read,
with the FormatNumber function:

lngValue = 1073197056
Wscript.Echo FormatNumber(lngValue, 0)

You can also convert bytes to gigabytes by dividing by 2^30
(1,073,741,824).

Wscript.Echo FormatNumber(lngValue/2^30, 3)

The second parameter in the FormatNumber function is the number of digits
to
display after the decimal.

--
Richard
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net



.


Loading