CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2005
    Posts
    568

    Convert double to CString with 2 decimal places

    How can i convert a double value to CString with 2 decimal places?
    eg double value is 23, i want it to convert to CString with 23.00 while i using _gcvt it just return me 23.

    can any help one this?

  2. #2
    Join Date
    Aug 2008
    Location
    Scotland
    Posts
    379

    Re: Convert double to CString with 2 decimal places

    Hi,
    Code:
    CString myString;
    double myDouble = 23.0;
    
    myString.Format(_T("%.2f"),myDouble);
    Have a look at the documentation for CString for more details.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured