Public Class Form1 'output methods Sub say(ByVal s As String) 'output a string to the listbox Me.output.Items.Add(s) 'display the string s in listbox End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 'divide, but check for div by zero. output result (or err msg) Dim a, b As Double 'first and second input Dim result As Double 'result of operation Dim msg As String ' the output string will be composed here Dim what As String = "quotient" 'result type '1 input: get a,b a = CDbl(Me.txtfirst.Text) b = CDbl(Me.txtsecond.Text) '2 process: compute the quotient, but first check for /0 If (b <> 0) Then result = a / b msg = "the " & what & " is " & Format(result) Else msg = "!! denominator cannot be zero!" End If '3 output: show the answer say(msg) End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click 'multiply 2 #s output result (or err msg) Dim a, b As Double 'first and second input Dim result As Double 'result of operation Dim msg As String ' the output string will be composed here Dim what As String = "product" 'result type '1 input: get a,b a = CDbl(Me.txtfirst.Text) b = CDbl(Me.txtsecond.Text) '2 process: compute the product result = a * b msg = "the " & what & " is " & Format(result) '3 output: show the answer say(msg) End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click ' add 2 #s . output result. Dim a, b As Double 'first and second input Dim result As Double 'result of operation Dim msg As String ' the output string will be composed here Dim what As String = "sum " 'result type '1 input: get a,b a = CDbl(Me.txtfirst.Text) b = CDbl(Me.txtsecond.Text) '2 process: add a,b result = sum(a, b) msg = "the " & what & "is " & Format(result) '3 output: show the answer say(msg) End Sub Function sum(ByVal a As Double, ByVal b As Double) As Double 'return the sum of a and b Dim result As Double result = a + b Return result End Function Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click ' subtract 2 #s . output result. Dim a, b As Double 'first and second input Dim result As Double 'result of operation Dim msg As String ' the output string will be composed here Dim what As String = "difference " 'result type '1 input: get a,b a = CDbl(Me.txtfirst.Text) b = CDbl(Me.txtsecond.Text) '2 process: subtract a,b result = a - b msg = "the " & what & "is " & Format(result) '3 output: show the answer say(msg) End Sub Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click Me.Close() End Sub Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click txtfirst.Clear() txtsecond.Clear() Me.output.Items.Clear() End Sub End Class