Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FormatCurrency

Status
Not open for further replies.

TheBugSlayer

Programmer
Sep 22, 2002
887
US
Hi. I am using the FormatCurrency in my code but sometimes it works fine and sometimes it fails with the message:

Error Type:
Microsoft VBScript runtime (0x800A000D)
Type mismatch: 'FormatCurrency'
/cscbonus/Operatorbonus.asp, line 181


I am using it like either
Code:
<TD align=right> <%=FormatCurrency(rs("RegRate"))%>	</TD>
or
Code:
<TD align=right> <%=FormatCurrency(Bonus, 2, -1)%>	</TD>

The values format are not that big, less than a million in any case.

Your help is appreciated.
 
Make sure your rs("RegRate") is not NULL or not an empty string.



 
Also check isNumeric

Code:
Dim intPrice
intPrice = rs("RegRate")

If intPrice <> "" AND isNumeric(intPrice) then
intPrice = FormatCurrency(intPrice)
   Else
intPrice = "$0.00"
End If

But this should be checked when it goes in the database, and make it a 0 if its null, so then you don't have to check it on the way out.

Jason

www.sitesd.com
ASP WEB DEVELOPMENT
 
Thank you guys, I am indeed getting NULL values. Very strange but it is happening; that data is retrieved from a table that contains only positive numbers, no null no zero values. So I guess if I fix that I will be OK.

Thank you again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top