Click to See Complete Forum and Search --> : How to limit calculated price variables to return only 2 decimal place?


AnaFyr
11-18-2003, 03:18 PM
Trying to find a way to get a integer variable to return only 2 decimal places.
I understand one can force a variable with conversion agents like; CCur or CDbl. Is this how I need to do it?

Now I get this: $234.87654

I want this: $234.87

A copy of my code and how I'm using it:


!COMMENT--HERE ARE SOME OF MY VARIABLES

Dim MultipliedTaxes
MultipliedTaxes = (TotalProductsPrice + TotalTax)

Dim FinalPriceWithDelivery
FinalPriceWithDelivery = (MultipliedTaxes + AcquiredDeliveryFee)



!COMMENT--HERE I'M RETURNING VALUES TO THE PAGE

Response.Write "<TR ALIGN='center' VALIGN='middle'><TD COLSPAN='2'><B>FinalTotal:</B></TD><TD

BGCOLOR='#E0E0E0'><B><FONT COLOR='#CC0000'>$" & FinalPriceWithDelivery & "</FONT></B></TD></TR></TABLE><P><BR>"


Anyone?

rdoekes
11-21-2003, 01:04 PM
Dim MultipliedTaxes
MultipliedTaxes = (TotalProductsPrice + TotalTax)

Dim FinalPriceWithDelivery
FinalPriceWithDelivery = FormatNumber((MultipliedTaxes + AcquiredDeliveryFee), 2)

AnaFyr
11-22-2003, 12:05 AM
Originally posted by rdoekes

Dim MultipliedTaxes
MultipliedTaxes = (TotalProductsPrice + TotalTax)

Dim FinalPriceWithDelivery
FinalPriceWithDelivery = FormatNumber((MultipliedTaxes + AcquiredDeliveryFee), 2)



Thanks RDOEKIS,

I knew there was a method to help me address my problem. I've tried your example and, of course, it's working.

Thanks again RD...

Always great to know there is people out there willing to help the beginners.

Cheers...

CardboardHammer
11-24-2003, 02:11 AM
Dim FinalPriceWithDelivery
FinalPriceWithDelivery = FormatNumber((TotalProductsPrice + TotalTax + AcquiredDeliveryFee), 2)


If you're only showing FinalPriceWithDelivery, you can get rid of the other variable. (And I bet you can get rid of TotalTax by replacing it with it's calculation as well.)

EDIT: Then again, you may very well be using those variables for other things beyond the code you displayed...