CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Guest

    formated number in CEdit

    Hi,

    I have a dialog that contains CEdit boxes. They are attached to a member, as m_fValue. When m_fValue is close to 0, but not exactly 0 as 5.675799877e-10, I see only 5.6757 in the CEdit ! So the user get a wrong information.

    I can replace m_fValue by m_sValue and use m_sValue.Format("%5.3f",&m_fValue), but this is not elegant and I have to take care about the relevant format for each CEdit box.

    Is there an elegant way ?


  2. #2
    Join Date
    Apr 1999
    Posts
    306

    Re: formated number in CEdit

    I am not sure, but I think you variable is float. Make it double and everything will be ok.


  3. #3
    Guest

    Re: formated number in CEdit

    This is not a problem with float or double. This is only with display: my CEdit box is to small to display all characters, so the user don't the last characters so he gets the impression that the number is far form 0 !!!!

    Is there any possibility to force an appropriate display for numbers close to 0


  4. #4
    Join Date
    May 1999
    Location
    Miami, Florida
    Posts
    242

    Re: formated number in CEdit

    I am not sure whether this will help, but you can force a display by typing

    SetDlgItemText(IDC_EDITxx, "0.0");

    and you could setup something like

    if (m_fvalue < .00001) SetDlgItemText(....)

    I hope this helps.


  5. #5
    Join Date
    May 1999
    Posts
    37

    Re: formated number in CEdit

    This helps, but if I have to check values, I will prefer to write something like:

    1) add a member m_sValue to the CEdit

    2) when m_fValue is updated,

    m_sValue.Format("%7.3f",m_fValue);
    UpdateData(FALSE);

    And this is what I don't want to do, but it works...

    Yves Le Sant
    Metrology and Measurement Unit
    Fundamental and Experimental Aerodynamics Departement
    ONERA Meudon
    (Office National d'Etudes et de Recherches Aérospatiales)
    FRANCE

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