Subject: format total
Posted By: Adam H-W Post Date: 9/27/2004 9:23:24 AM
Hi there

Simple question - how do you format a number so that it outputs to a correct currency decimal place? i.e from 22.5 to 22.50?

thanks

Adam

Reply By: ChrisScott Reply Date: 9/27/2004 9:51:28 AM
Hi Adam,

If you're using VBScript, you can use FormatCurrency or FormatNumber, I tend to steer clear of FormatCurrency as this bangs a currency sign in based on your servers setiings.

formattedNumber = FormatNumber(yourNumber, decimalPlacesRequired)

If you're using JScript, you can roll your own function to do the same thing

function FormatNumber(pNum, pDPs){
    return (pNum * Math.pow(10, pDPs)).toString().replace(new RegExp("^(\\d*)(\\d{" + pDPs + "})$"), "$1.$2");
}

HTH,

Chris

Reply By: Adam H-W Reply Date: 9/27/2004 9:55:34 AM
great, thanks


Go to topic 17124

Return to index page 762
Return to index page 761
Return to index page 760
Return to index page 759
Return to index page 758
Return to index page 757
Return to index page 756
Return to index page 755
Return to index page 754
Return to index page 753