Displaying an float on an edit box 
Author Message
 Displaying an float on an edit box

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



Wed, 26 Feb 2003 07:42:06 GMT  
 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]



Wed, 26 Feb 2003 10:34:14 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Displaying Integers in an Edit Box or List Box

2. display double/float in static and edit control

3. Visual C++ edit box tabbing and floating numbers

4. floating values And edit box

5. Edit Box and Floating point numbers

6. floating values and Edit box

7. EDIT box float input

8. How can I create floating edit boxes?

9. press enter in an edit box and make it happen in an other edit box too

10. *** Edit box *** Edit Box *****

11. **** Edit box *** Edit box ***

12. Displaying Multiple lines in EDIT box

 

 
Powered by phpBB® Forum Software