Question: How can I get the below code to make the output only go two decimal places? The calculations are working correctly but I would like

How can I get the below code to make the output only go two decimal places? The calculations are working correctly but I would like to shorten the output.

Private Sub btnCalculate_Click(sender As Object, e As EventArgs) Handles btnCalculate.Click

Dim TargetedGoal As Double

Dim GoldWeight As Double

If (radOunces.Checked = True) Then

txtGoldAmount.Visible = False

lblGoldWeight.Visible = False

txtGoalAmount.Visible = True

lblGoalAmount.Visible = True

txtCalculate.Visible = True

lblCalculatedValue.Visible = True

TargetedGoal = CDbl(txtGoalAmount.Text) / 1168.67

txtCalculate.Text = CStr(TargetedGoal)

ElseIf (radGoldSold.Checked = True) Then

txtGoalAmount.Visible = False

lblGoalAmount.Visible = False

txtGoldAmount.Visible = True

lblGoldWeight.Visible = True

txtCalculate.Visible = True

lblCalculatedValue.Visible = True

GoldWeight = CDbl(txtGoldAmount.Text) * 1168.67

txtCalculate.Text = CStr(GoldWeight)

End If

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!