Formatting a currency AFTER a calculation

# Thread: Formatting a currency AFTER a calculation

1. Sage McEnery Guest

## Formatting a currency AFTER a calculation

Im making an autoresponder that adds two variable&#039s. One variable is a Grant Amount and teh other variable is a banks fee&#039s. Ive got the two values adding together correctly to get a sum, but the answer is formatted incorrectly. If the Sum ends in a zero, ASP is dropping the zero off, so the result looks like \$1234.5 instead of \$1234.50 . Does anybody know why this is? and how to fix it? Contact me on ICQ @ 67712870 or Email me @ FlinxNFlux@prodigy.net for an immediate response. I will help out all who answer anyway I can.. I need this done Today!!!

2. Max
Senior Member
Join Date
Dec 1969
Posts
250

## RE: Formatting a currency AFTER a calculation

FormatNumber(calculated_variable, 2)

3. Sage Guest

## RE: Formatting a currency AFTER a calculation

Thanks for the rapid Response Max. One question, Calculated_Variable would be the sum of my two variables correct??

4. pm
Senior Member
Join Date
Dec 1969
Posts
101

## RE: Formatting a currency AFTER a calculation

You can also use FormatCurrency instead. It takes care of everything.

5. Sage Guest

## RE: Formatting a currency AFTER a calculation

Whats wrong with this statement ???<BR>Function FormatNumber <BR>intTotal = (intAmount + intCount, 2)2<BR>End Function<BR> Or this<BR><BR>formatCurrency(intTotal)

6. Sage in HELL Guest

## This is just not working for me

&nbsp;<BR>intCount = strAdminFee<BR>intAmount = Request.Form("GrantAmount") <BR><BR>striCount = intAmount + intCount<BR>FormatCurrency(striCount + 0.01)<BR><BR>

7. Skippie Guest

## RE: Formatting a currency AFTER a calculation

Try this:<BR><BR>Before doing any calculations, turn the string into a number:<BR>After calculations, turn it back to a currency string.<BR><BR>Example:<BR><BR>&#060;%<BR>Function CurrencyToNumber(c)<BR>Dim s<BR><BR>s = Replace(c,"\$","")<BR>CurrencyToNumber = cDbl(Replace(s,",",""))<BR><BR>End Function<BR><BR><BR><BR><BR>price1 = "\$111.11"<BR>price2 = "\$222.22"<BR><BR>total = FormatCurrency(CurrencyToNumber(price1) + CurrencyToNumber(price2))<BR>Response.Write(total) <BR><BR>%&#062;<BR><BR><BR><BR>-- Skippie<BR><BR><BR><BR>

8. Sage Guest

## Skippie, you are the man

Skippie, you are the man.... You have made me and my boss very happy. I hope you would E-Mail me so I can ask something else of you.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•