Solved

floats and input/output

Posted on 1998-10-11
7
182 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
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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Strange date stored 22 117
sumDigits challenge 9 146
Not needed 13 109
Problem to open Excel file 15 128
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 Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
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.

815 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

11 Experts available now in Live!

Get 1:1 Help Now