CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    May 1999
    Location
    Arizona, U.S.A.
    Posts
    101

    Question Double to CString Conversion using fcvt

    Hi All,

    CString csRegHrs;
    csRegHrs.Empty();

    The next line produces the correct value Say 1000 (for 10.00) in csRegHrs.
    csRegHrs = fcvt(m_pDSet->m_REGHRS,2,&decimal,&sign);

    Can anyone explain to me why this isn't working.
    csRegHrs.Format("%0.2lf");
    The above line produces 0.00? Instead it should be 10.00?

    I have stepped through the code and when I step into the csRegHrs.Format portion of the code it indicates in red text that it is 0.00 instead of 10.00.

    I just don't get it. Any help would be appreciated.

    Thanks,
    Charlie

    Everything is Free Until You Have to Pay for it....

    Platform is Windows 2000/XP Professional, Visual C++ 6.0

  2. #2
    Join Date
    Aug 2000
    Location
    New York, NY, USA
    Posts
    5,656

    Re: Double to CString Conversion using fcvt

    Quote Originally Posted by Charlie Curtis
    Can anyone explain to me why this isn't working.
    csRegHrs.Format("%0.2lf");
    The above line produces 0.00? Instead it should be 10.00?
    The Format() method of CString takes a format string AND values that have to be formatted.
    Try:

    csRegHrs.Format("%0.2f", <your_value>);
    Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
    Convenience and productivity tools for Microsoft Visual Studio:
    FeinWindows - replacement windows manager for Visual Studio, and more...

  3. #3
    Join Date
    May 1999
    Location
    Arizona, U.S.A.
    Posts
    101

    Re: Double to CString Conversion using fcvt

    It's always the simple things that hang you up... That was what I missed I wasn't paying close enough to the format string portion. So I added it and sure enough it works fine now!

    Thanks for the help.
    Charlie
    Everything is Free Until You Have to Pay for it....

    Platform is Windows 2000/XP Professional, Visual C++ 6.0

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