locked
Using AfxMessageBox RRS feed

  • Question

  • How to display an double variable using AfxMessageBox or other similar?
    Friday, May 26, 2017 1:53 PM

All replies

  • There are many ways to construct a string for display but in an MFC environment it is common to do something like

    CString strMsg;
    double dblVar = 100.00;
    
    strMsg.Format(_T("Double value is %f"), dblVar);
    AfxMessageBox(strMsg);
    

    • Proposed as answer by Baron Bi Monday, May 29, 2017 6:54 AM
    Friday, May 26, 2017 2:19 PM
  • Internally CString::Format probably uses _fcvt_s and I think it is a matter of personal preference what you use. CString::Format at least is easier for the programmer.

    See Convert double to char and How to convert double to string in VC++.

    My Formatted MessageBox might be a useful a bit.



    Sam Hobbs
    SimpleSamples.Info

    Friday, May 26, 2017 8:59 PM
  • Hi artful1st,

    Has your case been solved?

    If it has, pleas help to mark answers. If not, just feel free to contact us.

    Your understanding and cooperation will be grateful.

    Best Regards,
    Sera Yu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, June 5, 2017 6:59 AM