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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how do you multiply 2 edit boxes to equal 1 using a button? 1

Status
Not open for further replies.

real

Programmer
Jan 20, 2001
15
US
i have 5 edit boxes, and 3 buttons.
1st box = first name
2nd box = last name , these are not important

3rd box = hours worked
4th box = pay rate , basic knowledge hrs x rate = total pay, using the calculate button

5th box = total pay

Im using visual c++, if anyone knows how to do this please reply, i cant get passed this. im currently lost.
 
real,

Use the 'Class Wizard' to set up the following:

*double variable for 'hours worked edit box', name (_nHoursWorked)
*double variable for 'pay rate', name (_nPayRate)
*CString variable for 'total pay', name (_sTotalPay)
*Message Handler for the 'Calculate' button, name ( OnCalculate)

I will assume you know how to do these things since they are fundamental aspects of Visual C++ MFC development and details are in all the tutorials.

Then this would be the code in OnCalulate:

void MyDialog::OnCalculate(){
// use DDX to copy window data into class varialbes
UpdateData();
_sTotalPay.Format("%9.2f", _nHoursWorked * _nPayRate);
// use DDX to copy variables into window controls
UpdateData(FALSE);
}

Hope this helps
-pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top