Public Class Form1 Dim mon, tue, wed, thu, fri, rate As Double Dim tot As Double Dim total As Double Dim overtime As Double '//// 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.Clear() iTues.Clear() iWeds.Clear() iThu.Clear() iFri.Clear() iRate.Clear() 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, rate As Double Dim tot As Double Dim total As Double Dim overtime As Double '1: INPUT: Get the two numbers. mon = getMon() tue = getTue() wed = getWed() thu = getThu() fri = getFri() rate = iRate.Text '2. PROCESS: Add them up, to calculate a result. tot = calcsum(mon, tue, wed, thu, fri) If tot > 40 Then overtime = (rate + (rate / 2)) * (tot - 40) End If '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) oResult.Items.Add("The Pay is " & FormatCurrency(rate * total + overtime)) 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 '0. DECLARATIONS: Dim mon, tue, wed, thu, fri, rate As Double Dim tot As Double Dim total As Double Dim overtime As Double '1: INPUT: Get the two numbers. mon = getMon() tue = getTue() wed = getWed() thu = getThu() fri = getFri() If (mon = 0) Then mon = mon + 8 End If rate = iRate.Text '2. PROCESS: Add them up, to calculate a result. tot = calcsum(mon, tue, wed, thu, fri) If tot > 40 Then overtime = (rate + (rate / 2)) * (tot - 40) End If '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) oResult.Items.Add("The Pay is " & FormatCurrency(rate * total + overtime)) End Sub Private Sub BtnXmas_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnXmas.Click '0. DECLARATIONS: Dim mon, tue, wed, thu, fri, rate As Double Dim tot As Double Dim total As Double '1: INPUT: Get the two numbers. mon = getMon() tue = getTue() wed = getWed() thu = getThu() fri = getFri() If (fri >= 4) Then fri = fri + 4 End If rate = iRate.Text '2. PROCESS: Add them up, to calculate a result. tot = calcsum(mon, tue, wed, thu, fri) If tot > 40 Then overtime = (rate + (rate / 2)) * (tot - 40) End If '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) oResult.Items.Add("The Pay is " & FormatCurrency(rate * total + overtime)) End Sub Private Sub BtnReport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnReport.Click '0. DECLARATIONS: Dim mon, tue, wed, thu, fri, rate As Double Dim tot As Double Dim total As Double Dim avg As Double Dim day As Double Dim small As String '1: INPUT: Get the two numbers. mon = getMon() tue = getTue() wed = getWed() thu = getThu() fri = getFri() Day = 0 rate = iRate.Text If mon > 8 Then Day = Day + 1 End If If tue > 8 Then Day = Day + 1 End If If wed > 8 Then day = day + 1 End If If thu > 8 Then day = day + 1 End If If fri > 8 Then day = day + 1 End If '2. PROCESS: Add them up, to calculate a result. tot = calcsum(mon, tue, wed, thu, fri) If tot > 40 Then overtime = (rate + (rate / 2)) * (tot - 40) End If avg = tot / 5 small = calcSmall(mon, tue, wed, thu, fri) '3. OUTPUT: Display the result (with a message) saywhat(" The numbers of hours worked are ", tot) saywhat(" The average number of hours worked are", avg) saywhat(" The number of days the employee worked more then 8 hours is", day) oResult.Items.Add("The smallest # of hours per day was " + small) '//////// CALCULATION METHODS: 'calculate the sum total = calcsum(mon, tue, wed, thu, fri) '//// output: oResult.Items.Add("The Pay is " & FormatCurrency(rate * total + overtime)) End Sub Function calcSmall _ (ByVal a As Double, ByVal b As Double, ByVal c As Double, ByVal d As Double, ByVal e As Double) _ As String '//// Calculate the smallest value. If (a < b) And a < c And a < d And a < e And a <> 0 And a <> b And a <> c And a <> d And a <> e Then Return ("Monday") End If If (a = b) Then Return ("Monday and Tuesday") End If If (a < c) And a < b And a < d And a < e And a <> 0 And a <> b And a <> c And a <> d And a <> e Then Return ("Monday") End If If (a = c) Then Return ("Monday and Wednesday") End If If (a < d) And a < b And a < c And a < e And a <> 0 And a <> b And a <> c And a <> d And a <> e Then Return ("Monday") End If If (a = d) Then Return ("Monday and Thursday") End If If (a < e) And a < b And a < c And a < d And a <> 0 And a <> b And a <> c And a <> d And a <> e Then Return ("Monday") End If If (a = e) Then Return ("Monday and Friday") End If If (b < a) And b < c And b < d And b < e And b <> 0 And b <> a And b <> c And b <> d And b <> e Then Return ("Tuesday") End If If (b < c) And b < a And b < d And b < e And b <> a And b <> c And b <> d And b <> e And b <> 0 Then Return ("Tuesday") End If If (b = c) Then Return ("Tuesday and Wednesday") End If If (b < d) And b < a And b < c And b < e And b <> a And b <> c And b <> d And b <> e And b <> 0 Then Return ("Tuesday") End If If (b = d) Then Return ("Tuesday and Thursday") End If If (b < e) And b < a And b < c And b < d And b <> a And b <> c And b <> d And b <> e And b <> 0 Then Return ("Tuesday") End If If (b = e) Then Return ("Tuesday and Friday") End If If (c < a) And c < b And c < d And c < e And c <> a And c <> b And c <> d And c <> e And c <> 0 Then Return ("Wednesday") End If If (c < b) And c < a And c < d And c < e And c <> a And c <> b And c <> d And c <> e And c <> 0 Then Return ("Wednesday") End If If (c < d) And c < a And c < b And c < e And c <> a And c <> b And c <> d And c <> e And c <> 0 Then Return ("Wednesday") End If If (c = d) Then Return ("Wednesday and Thursday") End If If (c < e) And c < a And c < b And c < d And c <> a And c <> b And c <> d And c <> e And c <> 0 Then Return ("Wednesday") End If If (c = e) Then Return ("Wednesday and Friday") End If If (d < a) And d < b And d < c And d < e And d <> a And d <> b And d <> c And d <> e And d <> 0 Then Return ("Thursday") End If If (d < b) And d < a And d < c And d < e And d <> a And d <> b And d <> c And d <> e And d <> 0 Then Return ("Thursday") End If If (d < c) And d < a And d < b And d < e And d <> a And d <> b And d <> c And d <> e And d <> 0 Then Return ("Thursday") End If If (d < e) And d < a And d < b And d < c And d <> a And d <> b And d <> c And d <> e And d <> 0 Then Return ("Thursday") End If If (d = e) Then Return ("Thursday and Friday") End If If (e < a) And e < b And e < c And e < d And e <> a And e <> b And e <> c And e <> d And e <> 0 Then Return ("Friday") End If If (e < b) And e < a And e < c And e < d And e <> a And e <> b And e <> c And e <> d And e <> 0 Then Return ("Friday") End If If (e < c) And e < a And e < b And e < d And e <> a And e <> b And e <> c And e <> d And e <> 0 Then Return ("Friday") End If If (e < d) And e < a And e < b And e < c And e <> a And e <> b And e <> c And e <> d And e <> 0 Then Return ("Friday") End If End Function Private Sub BtnElect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnElect.Click '0. DECLARATIONS: Dim mon, tue, wed, thu, fri, rate As Double Dim tot As Double Dim total As Double '1: INPUT: Get the two numbers. mon = getMon() tue = getTue() wed = getWed() thu = getThu() fri = getFri() If (tue > 0) Then tue = tue + 2 End If rate = iRate.Text '2. PROCESS: Add them up, to calculate a result. tot = calcsum(mon, tue, wed, thu, fri) If tot > 40 Then overtime = (rate + (rate / 2)) * (tot - 40) End If '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) oResult.Items.Add("The Pay is " & FormatCurrency(rate * total + overtime)) End Sub Private Sub BtnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnExit.Click '/// quit the form End End Sub End Class