Presentation is loading. Please wait.

Presentation is loading. Please wait.

Pay Example (PFirst98) Please use speaker notes for additional information!

Similar presentations


Presentation on theme: "Pay Example (PFirst98) Please use speaker notes for additional information!"— Presentation transcript:

1 Pay Example (PFirst98) Please use speaker notes for additional information!

2 PFirst98 Note that in this example, I first built a frame to hold the option buttons. This grouped the option buttons so that only one could be pressed. Option Buttons are used when the user must select just one of the options.

3 Frame I drew the frame on the form in the position where I wanted it. I then named it frmType. You can also see the Caption of Type Employee.

4 The Value for the Option Button is True to indicate the button is selected and False to indicate the button is not selected. False is the default. Option button

5 Option Button

6 Output This shows the output. Two are Full Time and one is Part Time. Amount Earned is calculated when the Calculate button is clicked.

7 Calculate Button

8 Option Explicit Dim wkAmtEarn As Integer Private Sub CmdCalc_Click() wkAmtEarn = 0 If OptPart = True Then wkAmtEarn = Val(TxtPayHr) * Val(TxtHrs) Else If Val(TxtHrs) > 40 Then wkAmtEarn = 40 * Val(TxtPayHr) + (Val(TxtHrs) - 40) * (1.5 * Val(TxtPayHr)) Else wkAmtEarn = Val(TxtPayHr) * Val(TxtHrs) End If TxtAmtEarn = Str(wkAmtEarn) 'Str converts numeric to text - not needed 'Integer will get only whole # answer - need single to get decimals End Sub Code for CmdCalc_Click() Part 1 Code for CmdCalc_Click() Part 1 wkAmtEarn is defined as an integer with the Dim statement. Because it is at the top in the General Declarations area, it is available to events that are coded beneath. In this example there is only one. wkAmtEarn is given an initial value of 0.

9 Option Explicit Dim wkAmtEarn As Integer Private Sub CmdCalc_Click() wkAmtEarn = 0 If OptPart = True Then wkAmtEarn = Val(TxtPayHr) * Val(TxtHrs) Else If Val(TxtHrs) > 40 Then wkAmtEarn = 40 * Val(TxtPayHr) + (Val(TxtHrs) - 40) * (1.5 * Val(TxtPayHr)) Else wkAmtEarn = Val(TxtPayHr) * Val(TxtHrs) End If TxtAmtEarn = Str(wkAmtEarn) 'Str converts numeric to text - not needed 'Integer will get only whole # answer - need single to get decimals End Sub Code for CmdCalc_Click() Part 2 Code for CmdCalc_Click() Part 2 If OptPart is True then the wkAmtEarn is calculated by multiplying the Val of the entry in TxtPayHr by the Val of the entry in TxtHrs. Else, we check to see if the Val in TxtHrs is greater than 40. If it is, the calculation includes overtime. If it is not, the calculation is the multiplication. Note the comments. Since there were two IF statements, both must be ended. The answer is converted to a string and put in the TxtAmtEarn text box on the form.


Download ppt "Pay Example (PFirst98) Please use speaker notes for additional information!"

Similar presentations


Ads by Google