pay example (pfirst98) please use speaker notes for additional information!

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

Upload: derek-lee

Post on 21-Jan-2016

216 views

Category:

Documents


0 download

TRANSCRIPT

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

Pay Example (PFirst98)

Please use speaker notes for additional information!

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

PFirst98PFirst98

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.

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

FrameFrame

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.

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

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 buttonOption button

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

Option ButtonOption Button

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

OutputOutput

This shows the output. Two are Full Time and one is Part Time.

Amount Earned is calculated when the Calculate button is clicked.

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

Calculate ButtonCalculate Button

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

Option ExplicitDim wkAmtEarn As Integer

Private Sub CmdCalc_Click()wkAmtEarn = 0If 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 IfEnd IfTxtAmtEarn = Str(wkAmtEarn)'Str converts numeric to text - not needed'Integer will get only whole # answer - need single to get decimalsEnd Sub

Code for CmdCalc_Click()

Part 1

Code for CmdCalc_Click()

Part 1wkAmtEarn 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.

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

Option ExplicitDim wkAmtEarn As Integer

Private Sub CmdCalc_Click()wkAmtEarn = 0If 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 IfEnd IfTxtAmtEarn = Str(wkAmtEarn)'Str converts numeric to text - not needed'Integer will get only whole # answer - need single to get decimalsEnd 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.