PDA

Click to See Complete Forum and Search --> : Decimal Places


Skeen
Oct 6th, 2000, 04:45 AM
Hello everyone,

This probably sounds really stupid, but can anyone tell me how to fromat numbers into two decimal places. I'm really stuck on this one - never had to do it before, and all the books I've seen just describe the ecimal data type.

Cheers

Skeen

Ianpbaker
Oct 6th, 2000, 05:12 AM
Hi skeen
sorry I didn't reply by ICQ (few problems with my computer)

To format numbers you use FormatNumber (wow, now that's uncanny)

here it is(taken from msdn)

FormatNumber(Expression [,NumDigitsAfterDecimal [,IncludeLeadingDigit [,UseParensForNegativeNumbers [,GroupDigits]]]])

Arguments
Expression

Required. Expression to be formatted.

NumDigitsAfterDecimal

Optional. Numeric value indicating how many places to the right of the decimal are displayed. Default value is -1, which indicates that the computer's regional settings are used.

IncludeLeadingDigit

Optional. Tristate constant that indicates whether or not a leading zero is displayed for fractional values. See Settings section for values.

UseParensForNegativeNumbers

Optional. Tristate constant that indicates whether or not to place negative values within parentheses. See Settings section for values.

GroupDigits

Optional. Tristate constant that indicates whether or not numbers are grouped using the group delimiter specified in the control panel. See Settings section for values.

Ian

Skeen
Oct 6th, 2000, 05:26 AM
Cheers Ian, I havn't got the MSDN library, wish I had,
Thanks again

Cheers 'n' beers
skeen

Ianpbaker
Oct 6th, 2000, 05:29 AM
If you go to http://msdn.microsoft.com

You can get to everything and a lot more. Takes a while sometimes to find what your looking for, but it is the number one resource for any thing microsofty

Ian

Wen Lie
Oct 6th, 2000, 11:10 AM
Do you think u can use Format Function for ASP / VB Script ??? Isn't it just for VB Reference ??? Not for ASP / VB Scripting ???
I've tried before, nd still can't use it...

Till now, I'm still using Round Function for formatting my decimal number.
And I'm still confuse about formatting my number into hundreds, thousands, million, etc...
or to format date...

Do you know how ???

Cheers,
Wen Lie

monte96
Oct 6th, 2000, 03:27 PM
FormatNumber will not round. It will truncate. Depends on your needs I guess.

You can't use 'Format' in VBScript- It's FormatCurrency, FormatNumber, and FormatDateTime