Solved

floats and input/output

Posted on 1998-10-11
7
196 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
Independent Software Vendors: 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

Suggested Solutions

Title # Comments Views Activity
Installing Microsoft R server on REDHAT or SUSE Linux 4 152
viewing source code from eclipse 13 110
haveThree challenge 22 123
NotAlone Challenge 20 88
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

726 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