View Full Version : FormatCurrency() Without the "$"
Morgoth
01-15-2003, 04:23 AM
I need to use the basic Format() function, so I can use this code:
Format(111.2, "#.00")
But ASP doesn't know what it is. Why?
Is there any way to have two decimal places (#.##) with the last number or both last ones, zero?
FormatCurrency() does it, but it add's the "$", and I don't want that.
Anyone?
Morgoth
01-15-2003, 04:37 AM
Ok, well, I guess I'll do this:
Replace(FormatCurrency(TOTAL * TAX * EXCHANGE_RATE),"$","")
Or
Mid(FormatCurrency(TOTAL * TAX * EXCHANGE_RATE),2)
Anyone know what the best function to use is?
I think Mid, cause it seems Replace would just be much more code to run inside the function itself, and the extra few characters. ;)
whammy
01-16-2003, 01:25 AM
Round(number,2)
FormatNumber(number,2)
I thought we already went over this a couple of months ago? :)
P.S. the "2" is the number of decimal places you want after the decimal. :D
If you need to replace a $ sign first, then just nest it like so:
myvar = Round(Replace(number,"$",""),2)
but I would either not allow them to type in a dollar sign, or just use one of the functions on my site instead, I didn't write them for my health, I actually update those functions or add to them depending on whatever the latest application was I had to write - so you can rest assured they were pretty well tested, since I don't update the functions unless they work in an application. :D
I generally write the functions at home when I have time, but I use them at work. If I find out something is wrong with one of them, I correct it. :D
http://www.solidscripts.com/downloads/functions.txt
Morgoth
01-16-2003, 05:37 AM
whammy, I am using these functions to get my money to show up like so:
$111.20
Or is I have to use the exchange rate for some other contry, I show this
¥2332.04
Now my problem was my 111.20 showed up as 111.2, and I needed the other zero. So since Format() doesn't work. I used the method I posted, above, and I removed the "$" symbol just incase it was a differnt contry.
Round(111.2,2) gives me 111.2 again, no extra zero!
And I didn't know about FormatNumber until now. I never found that format in my search.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.