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 .

Recommended Answers

All 4 Replies

[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. }

...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);

...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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.