Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple Edit Control Problem on MS Visual C++

Status
Not open for further replies.

fledglingScarcrow

Programmer
Jan 18, 2001
3
0
0
US
I am an experienced Borland C++ Builder Programmer,
but I recently started teaching myself VCPP.

OK here is the scenario:
There are 3 edit boxes and 1 button on a form,
Numbers are entered in the first two edit boxes,
How do you make the sum of the two numbers appear in the third edit box when you
click the button?
I know it sound simple, but I haven't been able to get it work!!!

I know some if not all of you can probably do this in your sleep.
If you can reply soon with entire OnButtonClick() function.

Thanks,
W
 
Do u have member variables created to yr edit controls using the class wizard.
Create them first, it makes life easier.
Assume these are the variables for each of the controls
m_edit1
m_edit2
m_edit3
All u need to do is
OnButtonClick ()
{
m_edit3 = m_edit1 + m_edit2;
UpdateData(true) // or false.. not sure which one
}
This is give u data in the third edit box.

Sriks
 
I know all about the class wizard.
I see up CString & Control m_variables for each control.

Did the simple addition, UpdateData(true&false)...

Didn't work.
Do I use int variables or what?
In C++Builder you can do math with AnsiStrings.

This has got to be simple.
Please Advise

If you can do it, send me the OnButtonClick() code...

Thanks,
W
 
fledglingScarcrow,

> I see up CString & Control m_variables for each control.

You want to choose 'int' for the 'Variable Type' on the 'Add Member Variable' dialog, instead of CString;

sriks,

> UpdateData(true) // or false.. not sure which one

In this case you need to call both, i.e.:


OnButtonClick ()
{
// read the data from the window controls into member variables
UpdateData(); // uses the 'true' default
m_edit3 = m_edit1 + m_edit2;
// write the data from the member variables into the windows controls
UpdateData(FALSE);
}


Hope this helps
-pete
 
Thank pete;

It worked I tried every variation in the past...
except UpdateData(false);

Thanks a Million
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top