ช่วยดูให้หน่อยค่ะ
ถ้ามันเกิด error อย่างนี้ คืออะไรอ่ะค่ะคือต้องส่งพรุ่งนี้แล้วอ่าค่ะช่วยดูให้หน่อยนะค่ะ
Error 2 Operator '+' cannot be applied to operands of type 'System.Windows.Forms.TextBox' and 'System.Windows.Forms.TextBox' D:\calculation2\calculation2\Form1.cs 105 43 calculation2
โค้ด ค่ะ
private void button1_Click(object sender, EventArgs e)
{
{
double watt, count, day, hour;
double unit1, unit2, unit3, unit4, unit5, unit6, unit7, unit8, unit9, unit10, unit11;
watt = double.Parse(textBox12.Text);
count = double.Parse(textBox1.Text);
hour = double.Parse(textBox25.Text);
day = double.Parse(textBox36.Text);
unit1 = (watt / 1000 * count) * hour * day;
textBox37.Text = Convert.ToString(unit1);
watt = double.Parse(textBox13.Text);
count = double.Parse(textBox2.Text);
hour = double.Parse(textBox26.Text);
day = double.Parse(textBox23.Text);
unit2 = (watt / 1000 * count) * hour * day;
textBox46.Text = Convert.ToString(unit2);
watt = double.Parse(textBox14.Text);
count = double.Parse(textBox3.Text);
hour = double.Parse(textBox27.Text);
day = double.Parse(textBox24.Text);
unit3 = (watt / 1000 * count) * hour * day;
textBox47.Text = Convert.ToString(unit3);
watt = double.Parse(textBox15.Text);
count = double.Parse(textBox4.Text);
hour = double.Parse(textBox28.Text);
day = double.Parse(textBox38.Text);
unit4 = (watt / 1000 * count) * hour * day;
textBox48.Text = Convert.ToString(unit4);
watt = double.Parse(textBox16.Text);
count = double.Parse(textBox5.Text);
hour = double.Parse(textBox29.Text);
day = double.Parse(textBox39.Text);
unit5 = (watt / 1000 * count) * hour * day;
textBox49.Text = Convert.ToString(unit5);
watt = double.Parse(textBox17.Text);
count = double.Parse(textBox6.Text);
hour = double.Parse(textBox30.Text);
day = double.Parse(textBox40.Text);
unit6 = (watt / 1000 * count) * hour * day;
textBox50.Text = Convert.ToString(unit6);
watt = double.Parse(textBox18.Text);
count = double.Parse(textBox7.Text);
hour = double.Parse(textBox31.Text);
day = double.Parse(textBox41.Text);
unit7 = (watt / 1000 * count) * hour * day;
textBox51.Text = Convert.ToString(unit7);
watt = double.Parse(textBox19.Text);
count = double.Parse(textBox8.Text);
hour = double.Parse(textBox32.Text);
day = double.Parse(textBox42.Text);
unit8 = (watt / 1000 * count) * hour * day;
textBox52.Text = Convert.ToString(unit8);
watt = double.Parse(textBox20.Text);
count = double.Parse(textBox9.Text);
hour = double.Parse(textBox33.Text);
day = double.Parse(textBox43.Text);
unit9 = (watt / 1000 * count) * hour * day;
textBox53.Text = Convert.ToString(unit9);
watt = double.Parse(textBox21.Text);
count = double.Parse(textBox10.Text);
hour = double.Parse(textBox34.Text);
day = double.Parse(textBox44.Text);
unit10 = (watt / 1000 * count) * hour * day;
textBox54.Text = Convert.ToString(unit10);
watt = double.Parse(textBox22.Text);
count = double.Parse(textBox11.Text);
hour = double.Parse(textBox35.Text);
day = double.Parse(textBox45.Text);
unit11 = (watt / 1000 * count) * hour * day;
textBox55.Text = Convert.ToString(unit11);
SumBox = Convert.ToString(textBox37 + textBox46 + textBox47 + textBox48 +textBox49 +textBox50 +textBox51 + textBox52 +textBox53 + textBox54 +textBox55);
}
}
private void button2_Click(object sender, EventArgs e)
{
{
double total;
double Sum = Convert.ToDouble(textBox37.Text);
double service = 8.19;
if (Sum <= 15)
{
total = (Sum * 1.8632) + service;
}
else if (Sum <= 25)
{
total = (Sum * 2.5026) + service;
}
else if (Sum <= 35)
{
total = (Sum * 2.7549) + service;
}
else if (Sum <= 100)
{
total = (Sum * 3.1381) + service;
}
else if (Sum <= 150)
{
total = (Sum * 3.2315) + service;
}
else if (Sum <= 400)
{
total = (Sum * 3.7362) + service;
}
else
{
total = (Sum * 3.9361) + service;
}
TotaltextBox.Text = Convert.ToString(total);
}
}
}
}
Error 2 Operator '+' cannot be applied to operands of type 'System.Windows.Forms.TextBox' and 'System.Windows.Forms.TextBox' D:\calculation2\calculation2\Form1.cs 105 43 calculation2
โค้ด ค่ะ
private void button1_Click(object sender, EventArgs e)
{
{
double watt, count, day, hour;
double unit1, unit2, unit3, unit4, unit5, unit6, unit7, unit8, unit9, unit10, unit11;
watt = double.Parse(textBox12.Text);
count = double.Parse(textBox1.Text);
hour = double.Parse(textBox25.Text);
day = double.Parse(textBox36.Text);
unit1 = (watt / 1000 * count) * hour * day;
textBox37.Text = Convert.ToString(unit1);
watt = double.Parse(textBox13.Text);
count = double.Parse(textBox2.Text);
hour = double.Parse(textBox26.Text);
day = double.Parse(textBox23.Text);
unit2 = (watt / 1000 * count) * hour * day;
textBox46.Text = Convert.ToString(unit2);
watt = double.Parse(textBox14.Text);
count = double.Parse(textBox3.Text);
hour = double.Parse(textBox27.Text);
day = double.Parse(textBox24.Text);
unit3 = (watt / 1000 * count) * hour * day;
textBox47.Text = Convert.ToString(unit3);
watt = double.Parse(textBox15.Text);
count = double.Parse(textBox4.Text);
hour = double.Parse(textBox28.Text);
day = double.Parse(textBox38.Text);
unit4 = (watt / 1000 * count) * hour * day;
textBox48.Text = Convert.ToString(unit4);
watt = double.Parse(textBox16.Text);
count = double.Parse(textBox5.Text);
hour = double.Parse(textBox29.Text);
day = double.Parse(textBox39.Text);
unit5 = (watt / 1000 * count) * hour * day;
textBox49.Text = Convert.ToString(unit5);
watt = double.Parse(textBox17.Text);
count = double.Parse(textBox6.Text);
hour = double.Parse(textBox30.Text);
day = double.Parse(textBox40.Text);
unit6 = (watt / 1000 * count) * hour * day;
textBox50.Text = Convert.ToString(unit6);
watt = double.Parse(textBox18.Text);
count = double.Parse(textBox7.Text);
hour = double.Parse(textBox31.Text);
day = double.Parse(textBox41.Text);
unit7 = (watt / 1000 * count) * hour * day;
textBox51.Text = Convert.ToString(unit7);
watt = double.Parse(textBox19.Text);
count = double.Parse(textBox8.Text);
hour = double.Parse(textBox32.Text);
day = double.Parse(textBox42.Text);
unit8 = (watt / 1000 * count) * hour * day;
textBox52.Text = Convert.ToString(unit8);
watt = double.Parse(textBox20.Text);
count = double.Parse(textBox9.Text);
hour = double.Parse(textBox33.Text);
day = double.Parse(textBox43.Text);
unit9 = (watt / 1000 * count) * hour * day;
textBox53.Text = Convert.ToString(unit9);
watt = double.Parse(textBox21.Text);
count = double.Parse(textBox10.Text);
hour = double.Parse(textBox34.Text);
day = double.Parse(textBox44.Text);
unit10 = (watt / 1000 * count) * hour * day;
textBox54.Text = Convert.ToString(unit10);
watt = double.Parse(textBox22.Text);
count = double.Parse(textBox11.Text);
hour = double.Parse(textBox35.Text);
day = double.Parse(textBox45.Text);
unit11 = (watt / 1000 * count) * hour * day;
textBox55.Text = Convert.ToString(unit11);
SumBox = Convert.ToString(textBox37 + textBox46 + textBox47 + textBox48 +textBox49 +textBox50 +textBox51 + textBox52 +textBox53 + textBox54 +textBox55);
}
}
private void button2_Click(object sender, EventArgs e)
{
{
double total;
double Sum = Convert.ToDouble(textBox37.Text);
double service = 8.19;
if (Sum <= 15)
{
total = (Sum * 1.8632) + service;
}
else if (Sum <= 25)
{
total = (Sum * 2.5026) + service;
}
else if (Sum <= 35)
{
total = (Sum * 2.7549) + service;
}
else if (Sum <= 100)
{
total = (Sum * 3.1381) + service;
}
else if (Sum <= 150)
{
total = (Sum * 3.2315) + service;
}
else if (Sum <= 400)
{
total = (Sum * 3.7362) + service;
}
else
{
total = (Sum * 3.9361) + service;
}
TotaltextBox.Text = Convert.ToString(total);
}
}
}
}
ไม่มีหมายเลขบรรทัดเลยไม่รู้ว่าบรรทัดไหน ลองหาดูนะครับ