954,498 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How to Display in Edit Control, the data stored in a Double data type variable

i am calculating some expressions and the result of these expressions is a DOUBLE type value , i am storing this result into a double type variable called Sum . now i want to write this value of Sum into the Edit Control of a Dialog Based MFC application . the name of the Edit Control is IDC_DISPLAY

If you can give me example of how to do it then more good .

anuj.juthani
Newbie Poster
7 posts since Jan 2012
Reputation Points: 10
Solved Threads: 0
 

[Way-back in memory]
If you assign the control a variable, you can write to it directly.

...if you attach a CString to the control -- naming it strData, you can
issue a command like strData = { converting the double to a string and placing it here. }

thines01
Postaholic
Team Colleague
2,424 posts since Oct 2009
Reputation Points: 445
Solved Threads: 402
 

...looking more into this:
If you right-click the edit control, you will get a menu.
Choose "Add Variable"
A dialog box will appear.
Change the "category" to "value" and the variable type will change to CString.
Put in a Variable Name like strData
...click Finish

I added some code to format the string and the proper value appeared in the edit box.

double dbl = 123.45;
   strData.Format("%02.02f", dbl);
thines01
Postaholic
Team Colleague
2,424 posts since Oct 2009
Reputation Points: 445
Solved Threads: 402
 

...looking more into this: If you right-click the edit control, you will get a menu. Choose "Add Variable" A dialog box will appear. Change the "category" to "value" and the variable type will change to CString. Put in a Variable Name like strData ...click Finish

I added some code to format the string and the proper value appeared in the edit box.

double dbl = 123.45;
   strData.Format("%02.02f", dbl);

At first let me thank you for the time and thoughts . secondly my problem got solved , see i explain u what problem it was

i was trying by the same way as u suggested me , but the problem was very minute .
i was doing m_Display.Format("%f",Sum); where m_Display is same as strData of ur example. but in visual studio 2010 it was giving an error , so what i did is this
m_Display.Format(_T("%f"),Sum);

and it worked.....
thank u and keep writing to further posts too ! be blessed

anuj.juthani
Newbie Poster
7 posts since Jan 2012
Reputation Points: 10
Solved Threads: 0
 

Are you using the Unicode character set?
I switched mine to MultiByte.
...should have mentioned that...

thines01
Postaholic
Team Colleague
2,424 posts since Oct 2009
Reputation Points: 445
Solved Threads: 402
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: