Solved

Calculating

Posted on 1998-08-01
2
242 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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

762 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now