Public Class Form1 '//// IDENT.: calc3.vb '//// PURPOSE: Form to calculate various arithmetic results from two input values. '//// AUTHOR: Danielle C Private Sub bAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bAdd.Click '//// Add two values, and display the result. '0. DECLARATIONS: Dim a As Double ' The first number Dim b As Double ' The second number Dim result As Double ' The resulting value, from the calc. '1: INPUT: Get the two numbers. a = getA() ' Get the first and second values b = getB() '2. PROCESS: Add them up, to calculate a result. result = calcSum(a, b) '3. OUTPUT: Display the result (with a message) saywhat("The sum is ", result) End Sub '//////// INPUT METHODS: Function getA() As Double 'Get the first value. Dim result As Double result = Val(Me.iFirst.Text) Return result End Function Function getB() As Double 'Get the 2nd value. Dim result As Double result = Val(Me.iSecond.Text) Return result End Function '//////// CALCULATION METHODS: Function calcSum(ByVal a As Double, ByVal b As Double) As Double 'calculate the sum) Return a + b End Function Function calcMul(ByVal a As Double, ByVal b As Double) As Double 'calculate the sproduct Return a * b End Function '//////// OUTPUT METHODS: Sub saywhat(ByVal s As String, ByVal v As Double) 'Display a value, preceded by a msg say(s & " " & Format(v)) End Sub Sub say(ByVal s As String) 'Show a str Me.Result.Items.Add(s) End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnmult.Click '//// Multiply two values, and display the result. '0. DECLARATIONS: Dim a As Double ' The first number Dim b As Double ' The second number Dim result As Double ' The resulting value, from the calc. '1: INPUT: Get the two numbers. a = getA() ' Get the first and second values b = getB() '2. PROCESS: Multiply them up, to calculate a result. result = calcMul(a, b) '3. OUTPUT: Display the result (with a message) saywhat("The product is ", result) End Sub Private Sub Label2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) End Sub Private Sub Result_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Result.SelectedIndexChanged End Sub Private Sub clear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles clear.Click '/// clear the result Result.Items.Clear() End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub Private Sub BtnMax_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnMax.Click '//// Say which is the bigger number '0. DECLARATIONS: Dim a As Double ' The first number Dim b As Double ' The second number Dim result As Double ' The resulting value, from the calc. '1: INPUT: Get the two numbers. a = getA() ' Get the first and second values b = getB() '2. PROCESS: calculate a result. result = calcBigger(a, b) '3. OUTPUT: Display the result (with a message) saywhat("The bigger # is ", result) End Sub Function calcbigger(ByVal a As Double, ByVal b As Double) '//// return whichever is bigger Dim result As Double If (a > b) Then result = a Else result = b End If Return result End Function End Class