I'm Doing a simple Math calculator but I want to include the
following items
For the sume
When I test the program with 99999 + 99999. This should raise a 'System.OverflowException’ exception.
I want to modify the code to catch and handle the exception so that the user can continue.I want to keep the declarations of FirstNum and SecondNum as short.
For the Division
When I test the program with ‘9 divide 0’. The result shows ‘infinity’. Actually, I want the calculation should raise an exception ‘System.DivideByZeroException’.Also I want to modify the program so that the user input is validated before the divide operation is performed. For a divide by zero, I want to modify the program to raise an exception, then add the code to handle the exception.
For the multiplication
When I perform the test on (99 * 999). I got a 'System.OverflowException’ exception. I want to Fix the problem to handle the exception.
Now when I test the '-' operator using the following test cases: (1) variable1 = 32000 and variable2 = -767 and (2) variable1 = 32000 and variable2 = -768. For the first test case, the result should be 32767. For the second test case, you should get an exception and I want to find a solution
Here is my code:
Public Class Form1
Inherits System.Windows.Forms.Form
Dim FirstNum, SecondNum As Short
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'Assign text box values to variables
FirstNum = TextBox1.Text
SecondNum = TextBox2.Text
'Determine checked button and calculate
If RadioButton1.Checked = True Then
TextBox3.Text = FirstNum + SecondNum
End If
If RadioButton2.Checked = True Then
TextBox3.Text = FirstNum - SecondNum
End If
If RadioButton3.Checked = True Then
TextBox3.Text = FirstNum * SecondNum
End If
Try ' I try this to see if works but don't work
Err.Raise(11)
If RadioButton4.Checked = True Then
TextBox3.Text = FirstNum / SecondNum
End If
Catch When Err.Number = 11
MsgBox("Don't Divide 9/0")
End Try
End Sub
Can anybody Help me?

following items
For the sume
When I test the program with 99999 + 99999. This should raise a 'System.OverflowException’ exception.
I want to modify the code to catch and handle the exception so that the user can continue.I want to keep the declarations of FirstNum and SecondNum as short.
For the Division
When I test the program with ‘9 divide 0’. The result shows ‘infinity’. Actually, I want the calculation should raise an exception ‘System.DivideByZeroException’.Also I want to modify the program so that the user input is validated before the divide operation is performed. For a divide by zero, I want to modify the program to raise an exception, then add the code to handle the exception.
For the multiplication
When I perform the test on (99 * 999). I got a 'System.OverflowException’ exception. I want to Fix the problem to handle the exception.
Now when I test the '-' operator using the following test cases: (1) variable1 = 32000 and variable2 = -767 and (2) variable1 = 32000 and variable2 = -768. For the first test case, the result should be 32767. For the second test case, you should get an exception and I want to find a solution
Here is my code:
Public Class Form1
Inherits System.Windows.Forms.Form
Dim FirstNum, SecondNum As Short
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'Assign text box values to variables
FirstNum = TextBox1.Text
SecondNum = TextBox2.Text
'Determine checked button and calculate
If RadioButton1.Checked = True Then
TextBox3.Text = FirstNum + SecondNum
End If
If RadioButton2.Checked = True Then
TextBox3.Text = FirstNum - SecondNum
End If
If RadioButton3.Checked = True Then
TextBox3.Text = FirstNum * SecondNum
End If
Try ' I try this to see if works but don't work
Err.Raise(11)
If RadioButton4.Checked = True Then
TextBox3.Text = FirstNum / SecondNum
End If
Catch When Err.Number = 11
MsgBox("Don't Divide 9/0")
End Try
End Sub
Can anybody Help me?