Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vbscript round to 2 decimal places using Ccur

I am using CCur() instead of CDbl() as answered in this question:

vbscript mathematical expression not working

But I want to display amount to decimal places e.g 3 should be 3.00 and 3.555 should be 3.55.

How can I achieve this using CCur() function?

like image 289
khurram Avatar asked Dec 08 '22 19:12

khurram


1 Answers

CCur() is a "Convert to Currency" function, not a number formatting function.

Use following functions instead:

FormatNumber(number [,DecimalPlaces [,IncludeLeadingZero [,UseParenthesis [, GroupDigits]]]] )

or

FormatCurrency(Expression[,NumDigAfterDec[,IncLeadingDig[,UseParForNegNum[,GroupDig]]]])

number : The number to format.
DecimalPlaces : Number of digits to display after the decimal point.
IncludeLeadingZero : Include a leading zero for numbers <1 and > -1
UseParenthesis : Show negative numbers in Parentheis (500) = -500
GroupDigits : Group large numbers with commas (or the regional delimiter)

like image 144
ChiYoung Avatar answered Dec 11 '22 08:12

ChiYoung