Первого шанса исключение типа «System.FormatException» произошло в mscorlib.dllИсключения типа «System.FormatException» на double.Parse
Дополнительной информации: Входная строка не была в правильном формате.
Переход к этому коду сразу после
double parts = double.Parse(partsTextBox.Text);
Ничего на TextBox я должен ввести номер в приложении
и я попытался Try.Parse, и я получаю сообщение об ошибке «Нет перегрузки для метода« TryParse »принимает 1 аргумент«
, который у меня нет, что это значит.
В этом весь код
namespace Project03_18Mar15_Alan_Mederos_B
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void calculateTotalButton_Click(object sender, EventArgs e)
{
double oil = 0, lube = 0, radiator = 0, trans = 0, inspection = 0; double muffler = 0,tire = 0;
if (oilChangeBx.Checked == true)
{
oil = 26;
}
if (lubeJobBx.Checked == true)
{
lube = 18;
}
if (radiatorFlushBx.Checked == true)
{
radiator = 30;
}
if (transFlushBx.Checked == true)
{
trans = 80;
}
if (inspectionBx.Checked == true)
{
inspection = 15;
}
if (replaceMufflerBx.Checked == true)
{
muffler = 100;
}
if (tireRotationBx.Checked == true)
{
tire = 20;
}
// Convert all values to doubles
double parts = double.Parse(partsTextBox.Text);
double labor = double.Parse(laborTextBox.Text);
double oillube = OilLubeCharges(oil, lube);
double flush = FlushCharges(radiator, trans);
double misc = MiscCharges(inspection, muffler, tire);
double other = OtherCharges(parts, labor);
double tax = TaxCharges(parts, labor, oillube, flush, misc, labor);
double total = TotalCharges(oillube, flush, misc, other, tax);
double services = oillube + flush + misc;
servicesOutputLb.Text = services.ToString("c");
partsOutputLb.Text = other.ToString("c");
taxOutputLb.Text = tax.ToString("c");
totalOutputLb.Text = total.ToString("c");
}
private double OilLubeCharges (double oil, double lube)
{
//return oil and lube charges
return oil + lube;
}
private double FlushCharges(double radiator, double trans)
{
// returns radiator and transmission flush charges
return radiator + trans;
}
private double MiscCharges(double inspection, double muffler, double tire)
{
//return inspection, muffler, and tire rotation charges
return inspection + muffler + tire;
}
private double OtherCharges (double parts, double labor)
{
//return parts and labor
return parts + labor;
}
private double TaxCharges (double parts, double labor, double oillube,
double flush, double misc, double other)
{
//returns sales tax on parts only
if (parts != 0 && labor != 0 && (oillube != 0
&& flush != 0 && misc != 0 && other != 0))
{
// sales on tax is 6%
return (0.06 * parts);
}
else return 0;
}
private double TotalCharges(double oillube, double flush,
double misc, double other, double tax)
{
return oillube + flush + misc + other + tax;
}
private void clearBtn_Click(object sender, EventArgs e)
{
// Clears all fields
oilChangeBx.Checked = false;
lubeJobBx.Checked = false;
radiatorFlushBx.Checked = false;
transFlushBx.Checked = false;
inspectionBx.Checked = false;
replaceMufflerBx.Checked = false;
tireRotationBx.Checked = false;
partsTextBox.Text = "";
laborTextBox.Text = "";
servicesOutputLb.Text = "";
partsOutputLb.Text = "";
taxOutputLb.Text = "";
totalOutputLb.Text = "";
}
private void exitBtn_Click(object sender, EventArgs e)
{
//exits form
this.Close();
}
}
}
Вы посмотрели документацию? Также есть пример. https://msdn.microsoft.com/en-us/library/994c0zb1(v=vs.110).aspx –
Что находится в текстовом поле, когда это происходит? Ничего? –
да, ничего ... –