Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 27th, 2004, 09:23 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 347
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Adam H-W
Default format total

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

 
Old September 27th, 2004, 09:51 AM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

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.
Code:
formattedNumber = FormatNumber(yourNumber, decimalPlacesRequired)
If you're using JScript, you can roll your own function to do the same thing
Code:
function FormatNumber(pNum, pDPs){
    return (pNum * Math.pow(10, pDPs)).toString().replace(new RegExp("^(\\d*)(\\d{" + pDPs + "})$"), "$1.$2");
}
HTH,

Chris

 
Old September 27th, 2004, 09:55 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 347
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Adam H-W
Default

great, thanks






Similar Threads
Thread Thread Starter Forum Replies Last Post
date format differs, need to force format somehow patricolsson ASP.NET 2.0 Basics 1 December 3rd, 2009 12:53 AM
Convert British format date to American format? fyr PHP How-To 0 December 19th, 2007 03:17 PM
Convert Rich Text Format to Ordinary Format in ASP Andraw Classic ASP Basics 1 August 31st, 2007 10:05 AM
date format differs, need to force format somehow patricolsson HTML Code Clinic 2 January 12th, 2006 05:55 AM
format total number..not working rissay Access 5 February 23rd, 2004 09:10 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.