Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Pro Database Migration To Azure Data Modernization For The Enterprise

Authors: Kevin Kline, Denis McDowell, Dustin Dorsey, Matt Gordon

1st Edition

1484282299, 978-1484282298

More Books

Students also viewed these Databases questions

Question

2. Discuss the steps in preparing a manager to go overseas.

Answered: 1 week ago

Question

What is the most important part of any HCM Project Map and why?

Answered: 1 week ago