Class Notes
FUNCTIONS
o Look at the program on page 188, then pages 189-190
o Function program on pages 203-206
Program on
page 188
How do we test this program?
Dim firstnumber, secondnumber, thirdnumber As Integer
Dim sum, average As Double
Function readnumbers() 'READ NUMBERS FUNCTION
firstnumber = TextBox1.Text
secondnumber = TextBox2.Text
thirdnumber = TextBox3.Text
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
readnumbers()
Continuation…
Dim firstnumber, secondnumber, thirdnumber As Integer
Dim sum, average As Double
Function readnumbers() 'READ NUMBERS FUNCTION
firstnumber = TextBox1.Text
secondnumber = TextBox2.Text
thirdnumber = TextBox3.Text
End Function
Function printall()
MsgBox("FIRST NUMBER IS : " & firstnumber & vbNewLine & "SECOND NUMBER IS : " & secondnumber & vbNewLine & "THIRD NUMBER IS : " & thirdnumber & vbNewLine & "THE SUM IS : " & sum & vbNewLine)
TextBox4.Text = average
End Function
Function findsum()
sum = firstnumber + secondnumber + thirdnumber
End Function
Function findavg()
average = sum / 3.0
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
readnumbers()
findsum()
findavg()
printall()

Now, let’s do a
variation passing parameters through functions.
Dim firstnumber, secondnumber, thirdnumber
As
Integer
Dim average As Double
Function readnumbers() 'READ NUMBERS FUNCTION
firstnumber = TextBox1.Text
secondnumber = TextBox2.Text
thirdnumber = TextBox3.Text
End Function
Function findsum()
findsum = firstnumber + secondnumber + thirdnumber
End Function
Function findavg(ByVal sum)
average = sum / 3.0
End Function
Function printall(ByVal sum)
MsgBox("FIRST NUMBER IS : " & firstnumber & vbNewLine & "SECOND NUMBER IS : " & secondnumber & vbNewLine & "THIRD NUMBER IS : " & thirdnumber & vbNewLine & "THE SUM IS : " & sum & vbNewLine)
TextBox4.Text = average
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim sum As Double
readnumbers()
sum = findsum()
findavg(sum)
printall(sum)

Final Exam Summer session 2006
You to design a payroll software from scratch according to the following steps. For more information read the case study phase 5. Each step will be graded separately and has 10 points.
STEP1) Design a form with your company name with the command button called payroll. output will be displayed in any of your choices (textbox, label, list or even picture box) with corresponding labels according to the case study.
STEP2) Program the button to display only the input data
STEP3) display only Input data with gross pay
STEP4) Display only input data with regular pay and overtime pay
STEP5) display tax rate
step6) display taxrate according to the marital status
step7 ) display tax amount
step8) display netpay
step 9) search for an employee
step 10) sort and search for an employee