PDA

View Full Version : ASP & integers?


angst
01-10-2006, 04:50 PM
Hello,
I've made an asp script to calculate order totals,
my only problem is that integers seem to be rounded to a single decimal place, insted of a two digital decimal, for example.
before I submit the form, my javascript has calucated $4.30,
once I submit the form to the data base, it returns $4.3.

so my question is, how can I ensure that I get back an integer with two decimal places?

thanks in advance for your time!
-Ken

TheShaner
01-10-2006, 05:14 PM
Does it only do this on numbers like $12.40 and $1.20, where you have a zero in the hundredth place? If so, this can easily be corrected by applying a format with some ASP code.

FormatCurrency Function (http://www.w3schools.com/vbscript/func_formatcurrency.asp)

FormatNumber Function (http://www.w3schools.com/vbscript/func_formatnumber.asp)

For future reference, integers do not contain decimal places. In vbscript, this has to deal with currency, single, and double data types (even though in vbscript these data types are not specified as in regular VB code, they're inherited based on the value the variable receives)

-Shane

Bullschmidt
01-10-2006, 07:44 PM
before I submit the form, my javascript has calucated $4.30,
once I submit the form to the data base, it returns $4.3


Sounds like the same underlying number (4.3) to me although of course the formatting is different between the two.

angst
01-10-2006, 07:48 PM
yah, well.
you know it's the same number and I know it too,
but people are dumb, and see it see a proporly formated dollar value.

also big thanks for the tip on the "FormatCurrency Function",
I use something like this for php all the time, but never knew there was one for ASP/VB,, i even looked before I posted here. but I guess i missed it.

thanks again,
-Ken