Solved

MFC: formatting numeric field

Posted on 2007-04-02
2
273 Views
Last Modified: 2013-11-20
Hello,

Is there any standar function availavle in MFC that will add a comma (',')
to a numeric value (say monetary) to make the field easier to read.

for e.g.

   300.00 converted to 300.00 (no change)
  3000.00 -----> 3,000.00
 30000.00 -----> 30,000.00
300000.00 -----> 300,000.00


The environment is VC++ 6.0 and the monetary value is being displayed in edit box.

Thanks
0
Comment
Question by:pbsmbc
2 Comments
 
LVL 69

Accepted Solution

by:
Qlemo earned 125 total points
ID: 18837767
Best to use GetNumberFormatEx. You will have to format num to string with sprintf first, then put this into GetNumberFormatEx or GetNumberFormat.
0
 
LVL 19

Assisted Solution

by:alb66
alb66 earned 125 total points
ID: 18838082
You can use the COleCurrency class to convert monetary values in a standard way.
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

Suggested Solutions

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

713 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