Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

ASP.NET Forum


You are currently viewing our ASP.NET Forum as a guest. Please register to participate.
Login



Reply
Reverse FormatCurrency
Old 05-12-2006, 07:24 AM Reverse FormatCurrency
Skilled Talker

Posts: 95
Trades: 0
Hi,

I was wondering if anyone knows of any in built functions that would help me.
the scenerio is this.

I have a table that holds 4 fields yr1cost yr2cost and so on.
These fields are of the type float.

When i read the value from the DB to the ASP page i use

formatcurrency(costingRS("yr1cost"),0) which displays it nicely with the pound symbol and the seperater for when it reaches a thousand and more.

that is being written to a input box of a form so i can write it back to the table.
Only problem is i'm now trying to write to the DB values that contain commas if the bumber is over a thousand. and float doesnt like that.

my question id since there is a functio (formatcurrency) that converts a number into a currency value. Is thre a function that does the opposite. Ie a function that converts currecny into a number with out all the commas.

thank for you help
higginbt is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 05-12-2006, 08:06 AM Re: Reverse FormatCurrency
Skilled Talker

Posts: 95
Trades: 0
Ok i'm not sure if this is the best way of doing what i want but it works and its simply to implement.

since for some reason the date type float doesnt care about the £ sign it just ignores it but threw a wobbly at the seperating commas.

when i read the amount from the form to the object to in the sql string.

i was using

yr1cost = request.form("yr1cost")
this resulted in for example £3000,000,000 being passed in the sql not good.

i'm now using

yr1cost = replace(request.form("yr1cost"),",","")
which replaces all the , and replaces them with nothing. thus the value being passed inthe sql is £ 3000000000 which is good.


Last edited by higginbt; 05-12-2006 at 08:08 AM..
higginbt is offline
Reply With Quote
View Public Profile
 
Old 05-12-2006, 12:09 PM Re: Reverse FormatCurrency
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,938
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
Trades: 0
One thing you may want to do is add a function to convert your number to an actual number, just to be safe.

yr1cost=CDbl (Replace (Request.Form ("yr1cost"), ",", ""))

That way, you're sure it's a number. Of course, you could also go a step further and throw some validation in there to check it and make sure it's a number.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
(my blog)


Please login or register to view this content. Registration is FREE
(with proof)
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Old 05-18-2006, 06:56 AM Re: Reverse FormatCurrency
Skilled Talker

Posts: 95
Trades: 0
ADAM,

Thanks for your input.
I am using validation to make sure its a number. My problem which is solved now.

Was that if you entered 3000 which is how it was saved to the DB.
However when i display to the screen i use formactCurrecny(value,0) which displays 3000 as £3,000

Because users could see £3,000 i had to let them be able to type in £3,000 but this would cause the DB to have a fit as float although ignored the £ it could not cope with the ,

hope that made sense if not here is a short version

In England 3,000 is a valid number the validate number function allows it the DB doesnt so i had to get rid of the, some how which i have now done.
higginbt is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Reverse FormatCurrency
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.13055 seconds with 12 queries