Solved

Calculating

Posted on 1998-08-01
2
245 Views
Last Modified: 2010-04-02
I have been given a Name, Lastname, hour worked, Pay rate, and Total Pay for the static text. and when I hit the Calculate the total pay button, I should be able to calculate the certain amount of money in the Total pay edit box.
For example,
First Name: Mr. A
Last Name: BBB
Hours Worked: 10
Pay rate: 4.45
Total Pay: .....

and when I hit the Calculate button, I should be able to get the amount that Mr. A receive.

Thanks
0
Comment
Question by:Nung
2 Comments
 
LVL 4

Accepted Solution

by:
erajoj earned 200 total points
ID: 1169202
Are you using Visual C++ and MFC?
In that case; this is NOT hard!
Do you just have the payment data in the three static controls?
In that case:

1. Open your dialog and assign new names to the static controls. These are now called "IDC_STATIC" . Rename them to "IDC_HOURS" and  "IDC_PAYRATE" for instance. Also rename the edit box to "IDC_TOTALPAY".
2. Assign member variables to "IDC_HOURS",  "IDC_PAYRATE" and "IDC_TOTALPAY" using the classwizard. Use "add variable..." set names to m_sHours (IDC_HOURS), m_sPayrate (IDC_PAYRATE) and m_sTotalPay(IDC_TOTALPAY). Make sure category is "Value" and variable type is "CString".
3. Use the classwizard to connect the button to your code like this: Select your button in the "Object IDs"-list on the "Message Maps"-tab. Doubleclick the massage "BN_CLICKED". Set member function name to "OnCalcTotal". Press ok and then "Edit Code". Then enter:
    UpdateData(TRUE); // get data from controls
    m_sTotalPay.Format("%.2f", atof(m_sPayrate)*atof(m_sHours)); // calc&make string
    UpdateData(FALSE); // send data to controls

Build and run...
DONE!

/// John
0
 

Author Comment

by:Nung
ID: 1169203
thanks a lot ...maybe I may have some other question to border you again....but for this time..I appreciate it...thanks
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question