
Displaying an float on an edit box
Quote:
> Hey I'm pritty new to porgramming and am sort of teaching myself some basics
> of visual c++ but when I made a textbox with a variable of m_Payments and
> m_Principal and enter the following code
> ifstream myfile(FileName);
> myfile >> Principal >> Payment;
> m_Principal = Principal; // Principal is the name of a float
> m_Payments = Payment; // Payment is the name of a float
> UpdateData(FALSE);
> myfile.close();
> I get a | in my edit box or an . How do I make it so that I just get a
> number lik 3.01 or 6.84 or 1973.87 to display right? Its so confusing. if
> you can can you email the answer? ty.
> Gary Morrison
Analysis of the problem would need to know the data type of m_Principal.
To take control of the display format you can make m_Principal a CString type.
Then do m_Principal.Format("%f4.2", Principal);
UpdateData(FALSE);
This makes m_Principal a string of characters formatted as you specify after the
%f.
--
Scott McPhillips [VC++ MVP]