I'm having trouble with this part.My professor wants us to do this, when each button is clicked it 'gathers' the input and calls a sub named Result. I'm guessing we're suppose to use a Sub names Result that will call the other sub procedures.
this is what I have so far.
Can some one tell me how to do this?
Public Class Calculator
Sub Result(ByVal a As Integer, ByVal b As Integer, ByVal op As String)
End Sub
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
Try
AddedNum(CInt(txtFirstNum.Text), CInt(txtSecondNum.Text))
Catch e1 As OverflowException
MessageBox.Show("Number too large.", "Over Flow")
Catch e2 As Exception
MessageBox.Show("Enter a number.")
End Try
End Sub
Sub AddedNum(ByVal a As Integer, ByVal b As Integer)
Dim Total As String
Total = a + b.ToString
MessageBox.Show("Your total is " & Total.ToString, "Calculation", MessageBoxButtons.OK)
If Windows.Forms.DialogResult.OK Then
txtFirstNum.Clear()
txtSecondNum.Clear()
End If
End Sub
Private Sub btnSubtract_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubtract.Click
Try
SubtractedNum(CInt(txtFirstNum.Text), CInt(txtSecondNum.Text))
Catch e1 As OverflowException
MessageBox.Show("Number too large.", "Over Flow")
Catch e2 As Exception
MessageBox.Show("Enter a number.")
End Try
End Sub
Sub SubtractedNum(ByVal a As Integer, ByVal b As Integer)
Dim Total As String
Total = a - b.ToString
MessageBox.Show("Your total is " & Total.ToString, "Calculation", MessageBoxButtons.OK)
If Windows.Forms.DialogResult.OK Then
txtFirstNum.Clear()
txtSecondNum.Clear()
End If
End Sub
Private Sub btnMultiply_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMultiply.Click
Try
MultiplyNum(CInt(txtFirstNum.Text), CInt(txtSecondNum.Text))
Catch e1 As OverflowException
MessageBox.Show("Number too large.", "Over Flow")
Catch e2 As Exception
MessageBox.Show("Enter a number.")
End Try
End Sub
Sub MultiplyNum(ByVal a As Integer, ByVal b As Integer)
Dim Total As String
Total = a * b.ToString
MessageBox.Show("Your total is " & Total.ToString, "Calculation", MessageBoxButtons.OK)
If Windows.Forms.DialogResult.OK Then
txtFirstNum.Clear()
txtSecondNum.Clear()
End If
End Sub
Private Sub btnDevide_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDevide.Click
Try
DivideNum(CInt(txtFirstNum.Text), CInt(txtSecondNum.Text))
Catch e1 As OverflowException
MessageBox.Show("Number too large.", "Over Flow")
Catch e2 As DivideByZeroException
MessageBox.Show("Error.")
Catch e3 As Exception
MessageBox.Show("Enter a number.")
End Try
End Sub
Sub DivideNum(ByVal a As Integer, ByVal b As Integer)
Dim Total As String
Total = a / b.ToString
MessageBox.Show("Your total is " & Total.ToString, "Calculation", MessageBoxButtons.OK)
If Windows.Forms.DialogResult.OK Then
txtFirstNum.Clear()
txtSecondNum.Clear()
End If
End Sub
Private Sub btnPow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPow.Click
Try
PowNum(CInt(txtFirstNum.Text), CInt(txtFirstNum.Text))
Catch e1 As OverflowException
MessageBox.Show("Number too large.", "Over Flow")
Catch e2 As Exception
MessageBox.Show("Enter a number.")
End Try
End Sub
Sub PowNum(ByVal a As Integer, ByVal b As Integer)
Dim Total As String
Total = a ^ b.ToString
MessageBox.Show("Your total is " & Total.ToString, "Calculation", MessageBoxButtons.OK)
If Windows.Forms.DialogResult.OK Then
txtFirstNum.Clear()
txtSecondNum.Clear()
End If
End Sub
Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
txtFirstNum.Clear()
txtSecondNum.Clear()
End Sub
End Class