simonm0966
asked on
floats and input/output
I need to accept a float field on a dialog in currency format, and outout it in a rounded currency format to an edit box for display purposes ... the manual is not very helpful ,
does anyone have any advice ?
Thanks for reading
does anyone have any advice ?
Thanks for reading
I suggest trying to input a string instead, then you can count the number of digits after the decimal using a loop of some kind. Then when you are all done checking the number of digits, remove any of the excess by setting them to '\0'. Lastly you can convert the string to a float using something like atof.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hello :-)
I think Philip's solution is the best.
I think Philip's solution is the best.
Thanks thresh...
ASKER
Thanks Thresh, Phillip - I certainly appreciate the response. I have a question regarding your answer, how do I get the input process to look like its accepting a number only (it is a currency field), and are there any intrinsic functions to do the rounding for me ?
I did read somewhere about a COLECurrency object ?
I did read somewhere about a COLECurrency object ?
> How do I get the input process to look like its accepting a number only (it is a currency field).
The 9999.99 or ####.## type mask (I can't remember which is correct) should only allow numbers. What's missing?
> Are there any intrinsic functions to do the rounding for me ?
No. You'd have to write something manual.
> COleCurrency object?
is a way to store and handle the numbers once you receive them from the input device. It really doesn't help you much during the input procedure.
Phillip
The 9999.99 or ####.## type mask (I can't remember which is correct) should only allow numbers. What's missing?
> Are there any intrinsic functions to do the rounding for me ?
No. You'd have to write something manual.
> COleCurrency object?
is a way to store and handle the numbers once you receive them from the input device. It really doesn't help you much during the input procedure.
Phillip
ASKER
I must say that I'm surpised at the lack of intrinsic rounding.
Regarding the mask, I am presuming that this works for output too, so all I can say as a newbie is thanks for all your help, gentlemen.
Regarding the mask, I am presuming that this works for output too, so all I can say as a newbie is thanks for all your help, gentlemen.