Solved

floats and input/output

Posted on 1998-10-11
7
164 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
  • 3
  • 2
  • 2
7 Comments
 
LVL 6

Expert Comment

by:thresher_shark
Comment Utility
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
Comment Utility
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
Comment Utility
Hello :-)

I think Philip's solution is the best.
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 7

Expert Comment

by:psdavis
Comment Utility
Thanks thresh...
0
 

Author Comment

by:simonm0966
Comment Utility
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
Comment Utility
> 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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.

762 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now