Question: I am having trouble with the follow code. If a non-numeric value is entered I get my error message but after I click ok it

I am having trouble with the follow code. If a non-numeric value is entered I get my error message but after I click ok it still trys to do the calculation even though it was a non-neumeric value. Any suggestions would be appreciated.

Public Class frmCashForGold Private Sub radComputeTheWeight_CheckedChanged(sender As Object, e As EventArgs) Handles radComputeTheWeight.CheckedChanged ' User selects radio button to choose to calculat the goal amount lblEnterGold.Visible = False txtGoldAmount.Visible = False lblTargetGoal.Visible = True txtTargetGoal.Visible = True txtTotal.Text = "" txtGoldAmount.Text = ""

End Sub

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

End Sub

Private Sub radComputeTheAmount_CheckedChanged(sender As Object, e As EventArgs) Handles radComputeTheAmount.CheckedChanged lblTargetGoal.Visible = False txtTargetGoal.Visible = False lblEnterGold.Visible = True txtGoldAmount.Visible = True txtTargetGoal.Text = "" txtTotal.Text = "" End Sub

Private Sub btnCalculate_Click(sender As Object, e As EventArgs) Handles btnCalculate.Click Dim TargetGoal As Double Dim EnterGold As Double Dim Total As Double Dim PricePerOunce As Integer = 1168.67

If IsNumeric(txtTargetGoal.Text) AndAlso IsNumeric(txtGoldAmount.Text) Then TargetGoal = Convert.ToDecimal(txtTargetGoal.Text) EnterGold = Convert.ToDecimal(txtGoldAmount.Text) ElseIf Not IsNumeric(txtTargetGoal.Text) And Not IsNumeric(txtGoldAmount.Text) Then MessageBox.Show("Please enter a numeric value")

End If

If radComputeTheWeight.Checked = True Then Total = CDbl(txtTargetGoal.Text) / PricePerOunce ElseIf radComputeTheAmount.Checked = True Then Total = CDbl(txtGoldAmount.Text) * PricePerOunce End If

I am having trouble with the follow code. If a non-numeric value

Cash For Gold Cash For Gold Please Choose Your Option Please Select O Compute the weight in ounces to reach the goal amount O Compute the amount earned based on the weight of gold Target Goal Amount Enter the gold amount The calculated value is Calculate Clear

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!