Solved

floats and input/output

Posted on 1998-10-11
7
203 Views
Last Modified: 2013-11-20
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
0
Comment
Question by:simonm0966
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 6

Expert Comment

by:thresher_shark
ID: 1323172
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.
0
 
LVL 7

Accepted Solution

by:
psdavis earned 50 total points
ID: 1323173
See if you can use the Microsoft Masked Edit ActiveX control.  Add it to your project with 'Project - Add to Control - Registered ActiveX controls'. Then set the mask to 99999.99 for currency format.  Then grab the string from the edit field and convert the string to a float per thresher.

Hey thresh!

Phillip
0
 
LVL 6

Expert Comment

by:thresher_shark
ID: 1323174
Hello :-)

I think Philip's solution is the best.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 7

Expert Comment

by:psdavis
ID: 1323175
Thanks thresh...
0
 

Author Comment

by:simonm0966
ID: 1323176
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 ?  
0
 
LVL 7

Expert Comment

by:psdavis
ID: 1323177
> 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
0
 

Author Comment

by:simonm0966
ID: 1323178
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.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question