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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CSng

Status
Not open for further replies.

homeroid

Technical User
Joined
Dec 21, 2003
Messages
5
Location
GB
Hi All,

Im getting some data form the DB and then trying to convert it to another data type:

price = CCur(CSng(retriveRS("iprice") * vat))

iprice = 70.87596699

I keep getting a runtime error pointing to CSng.

However when I do CSng(70.87596699) it works.

All I need to do is bring iprice into 2 decimal places ie 70.87

Any help appreciated.
 
Change the recordset data to a single, then multiply by vat (which I hope is a single as well). Like this:

price = CCur(CSng(retriveRS("iprice")) * vat)
 
This error was ocurring because the record the code was accessing in the DB was non existant. I traped this by using the IsNull function and taking appropriate action.

Thanks for the tip.
 
Thanks for letting us know what worked!

Best regards,
J. Paul Schmidt, Freelance ASP Web Developer
ASP Design Tips, ASP Web Database Demo, Free ASP Bar Chart Tool...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top