Sign in to follow this  
vtbones

MFC question about CString

Recommended Posts

vtbones    122
I'm new to MFC and I'm trying to work with an edit box that needs to contain a dollar amount. As of right now, I'm trying to do this with a CString type variable. Is there a built-in/simple way to maintain the proper format of $xx.xx (w/o the $) using the CString type. In basic C++, I would just use a double set with a precision of 2 but I dont know if something like this can be done with MFC applications. Thanks in advance!

Share this post


Link to post
Share on other sites
SiCrane    11839
IIRC, if you wanted to load 10 dollars and 30 cents as the string it'd go like:

CString str;
str.Format("%2.2f", 10.3);

For more details check out the MSDN help files for CString::Format().

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this