Public Class Form1 '//// GLOBAl '//////// INPUT METHODS //////// Function getMon() As Integer ' '//// Return # hrs worked on Monday (from iMon). Dim result As Double Dim s As String s = Me.iMon.Text result = Val(s) Return result End Function Function getTue() As Integer '//// Return # hrs worked. Dim s As String = Me.iTues.Text Return Val(s) End Function Function getWed() As Integer ' '//// Return # hrs worked. Return Val(Me.iWeds.Text) End Function Function getThu() As Integer '//// Return # hrs worked. Dim s As String = Me.iThu.Text Return Val(s) End Function Function getFri() As Integer '//// Return # hrs worked. Dim s As String = Me.iFri.Text Return Val(s) End Function '//////// OUTPUT METHODS //////// Sub say(ByVal s As String) Me.oResult.Items.Add(s) End Sub Sub saywhat(ByVal s As String, ByVal x As Double) 'Output a string and a value Dim sx As String sx = s & " " & Format(x) say(sx) End Sub Sub saywhat(ByVal s As String, ByVal x As Integer) 'Output a string and a value Dim sx As String sx = s & " " & Format(x) say(sx) End Sub Private Sub BtnClear_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnClear.Click '/// clear the result oResult.Items.Clear() End Sub Private Sub BtnMWF_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnMWF.Click 'Change the label to green. Me.Label1.ForeColor = Color.Green Me.Label2.ForeColor = Color.Red Me.Label3.ForeColor = Color.Green Me.Label4.ForeColor = Color.Red Me.Label5.ForeColor = Color.Green End Sub Private Sub BtnTT_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnTT.Click 'Switch the label Colors. Me.Label1.ForeColor = Color.Red Me.Label2.ForeColor = Color.Green Me.Label3.ForeColor = Color.Red Me.Label4.ForeColor = Color.Green Me.Label5.ForeColor = Color.Red End Sub Private Sub BtnSame_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnSame.Click 'Change all the labels to yellow. Me.Label1.ForeColor = Color.Yellow Me.Label2.ForeColor = Color.Yellow Me.Label3.ForeColor = Color.Yellow Me.Label4.ForeColor = Color.Yellow Me.Label5.ForeColor = Color.Yellow End Sub Private Sub BtnReset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnReset.Click iMon.Text = 0 iTues.Text = 0 iWeds.Text = 0 iThu.Text = 0 iFri.Text = 0 End Sub Private Sub oResult_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles oResult.SelectedIndexChanged End Sub Private Sub BtnReg_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnReg.Click '//// Add hours, and display the total. '0. DECLARATIONS: Dim mon, tue, wed, thu, fri As Double Dim tot Dim total As Double '1: INPUT: Get the two numbers. mon = getMon() tue = getTue() wed = getWed() thu = getThu() fri = getFri() '2. PROCESS: Add them up, to calculate a result. tot = calcsum(mon, tue, wed, thu, fri) '3. OUTPUT: Display the result (with a message) saywhat(" The numbers of hours are ", tot) '//////// CALCULATION METHODS: 'calculate the sum total = calcsum(mon, tue, wed, thu, fri) '//// output: tot saywhat("the hours worked were ", total) End Sub Function calcsum(ByVal a As Double, ByVal b As Double, ByVal c As Double, ByVal d As Double, ByVal e As Double) As Double Return a + b + c + d + e End Function Private Sub BtnMonhol_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnMonhol.Click Dim mon As Double Dim holiday As Double mon = getMon() holiday = getMon() + 8 If (mon = 0) Then Return End If End Sub Private Sub BtnXmas_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnXmas.Click End Sub Private Sub BtnReport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnReport.Click 'Compute total and average '// INPUT: Get # of hrs, each day. Dim mon, tue, wed, thu, fri As Double mon = getMon() tue = getTue() wed = getWed() thu = getThu() fri = getFri() 'CALC: total & avg 'OUT: tot & avg '// PROCESS: Choose the largest value. Dim big As Double ' Largest # of hours big = calcBig(mon, tue, wed, thu, fri) '// OUTPUT: Greatest # of hours per day. saywhat("The greatest # of hours per day was ", big) End Sub Function calcBig _ (ByVal a As Double, ByVal b As Double, ByVal c As Double, ByVal d As Double, ByVal e As Double) _ As Double '//// Calculate the largest value. Dim r As Double r = a If (b > r) Then r = b End If If (c > r) Then r = c End If If (d > r) Then r = d End If If (e > r) Then r = e End If Return r End Function End Class