Can someone pls help me with some validation that im having a few technical problems with in my program.
First of all, I will explain to you a little about what my program is suppose to do. It consists of a form with two text boxes that allow the user to enter numbers. These numbers will either be added, subtracted, divided or multiplied by each other. The user will type which operant that they wish to use by using an additional text boxed provided on the form. The user will then click the calculate button which will display the result in another text box.
I want to add validation to stop the user from dividing a number by zero so that it stops the program from crashing and giving me a warning message about overflowException. I have copied and pasted my code for you to view. Thanks
Dim Total As Integer 'Declaration of Variables
Dim FirstNumber As Double
Dim SecondNumber As Double
Dim Operation As String
If IsNumeric(txtANumber.Text) = True Then
FirstNumber = txtANumber.Text
ElseIf IsNumeric(txtANumber.Text) = False Then
MsgBox("Please Enter a Numeric Value!", 48)
End If
If IsNumeric(txtBNumber.Text) = True Then
SecondNumber = txtBNumber.Text
ElseIf IsNumeric(txtBNumber.Text) = False Then
MsgBox("Please Enter a Numeric Value!", 48)
End If
If SecondNumber <= 0 Then
MsgBox("Please Enter a Numeric Greater than 0!", 48)
End If
Operation = txtOperation.Text
If Operation = "add" Then
Total = FirstNumber + SecondNumber
txtCurrentTotal.Text = Total
End If
If Operation = "subtract" Then
Total = FirstNumber - SecondNumber
txtCurrentTotal.Text = Total
End If
If Operation = "multiply" Then
Total = FirstNumber * SecondNumber
txtCurrentTotal.Text = Total
End If
If Operation = "divide" Then
Total = FirstNumber / SecondNumber
txtCurrentTotal.Text = Total
End If
End Sub