Public Class frmAdd

  Private Sub btnCompute_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCompute.Click
    'This program requests two numbers and
    'displays the two numbers and their sum.
    Dim x, y As Double
    GetNumbers(x, y)
    DisplaySum(x, y)
  End Sub

  Sub GetNumbers(ByRef x As Double, ByRef y As Double)
    'Record the two numbers in the text boxes
    x = CDbl(txtFirstNum.Text)
    y = CDbl(txtSecondNum.Text)
  End Sub

  Sub DisplaySum(ByVal num1 As Double, ByVal num2 As Double)
    'Display two numbers and their sum
    Dim sum As Double
    sum = num1 + num2
    txtResult.Text = "The sum of " & num1 & " and " &
                     num2 & " is " & sum & "."
  End Sub

End Class
