Public Class Form1 '//// IDENT.: calc3.vb '//// PURPOSE: Form to calculate various arithmetic results from two input values. '//// DESCRIPTION: '//// AUTHOR: B.A.Martin 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.oResult.Items.Add(s) End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.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 BBigger_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BBigger.Click Dim a As Double Dim b As Double 'return the bigger # Dim result As Boolean If (a > b) Then result = a Else result = b End If result = oResult End Sub End Class