?
Solved

floats and input/output

Posted on 1998-10-11
7
Medium Priority
?
206 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 150 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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.
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

770 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