Computer Guy
asked on
C# Method Issue
Hi,
When I click a button, I need to take the user entered wholesale price and custom percentage and pass them to a method as arguments and then return the value to a label.
Where did I mess up?
When I click a button, I need to take the user entered wholesale price and custom percentage and pass them to a method as arguments and then return the value to a label.
Where did I mess up?
private double CalculateRetail(double wholesale, double percentage)
{
return wholesale * percentage;
}
private void calculateButton_Click(object sender, EventArgs e)
{
double rp, retailPrice, wholesale, percentage;
if (double.TryParse(wholesaleTextBox.Text, out wholesale))
{
if (double.TryParse(percentageTextBox.Text, out percentage))
{
retailPrice = CalculateRetail(wholesale);
resultLabel.Text = rp.ToString("n1");
}
else
{
MessageBox.Show("Enter a Valid Price");
}
}
}
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Form1.cs -
Open in new window
Form1.Designer.cs -Open in new window
Produces the following results --saige-