Answer the question
In order to leave comments, you need to log in
How, when dividing by 0, to display the phrase in the textbox beyond the place of infinity?
'=' button
private void button17_Click(object sender, EventArgs e)
{
Double Value2 = Convert.ToDouble(textBox1.Text);
Double Result = Value2;
switch (Oper)
{
case 1:
Result = Value + Value2;
break;
case 2:
Result = Value - Value2;
break;
case 3:
Result = Value * Value2;
break;
case 4:
if (Value2 == 0)
{
textBox1.Text = "На 0 делить нельзя!";
}
else
{
Result = Value / Value2;
}
break;
}
textBox1.Text = Math.Round(Result,4).ToString();
Value = 0;
Oper = 0;
}
private void button4_Click(object sender, EventArgs e)
{
button17_Click(sender, e);
Value = Convert.ToDouble(textBox1.Text);
Oper = 4;
textBox1.Text = "0";
}
Answer the question
In order to leave comments, you need to log in
Something like this.
private void button17_Click(object sender, EventArgs e)
{
Double Value2 = Convert.ToDouble(textBox1.Text);
Double Result = Value2;
switch (Oper)
{
case 1:
Result = Value + Value2;
break;
case 2:
Result = Value - Value2;
break;
case 3:
Result = Value * Value2;
break;
case 4:
if (Value2 == 0)
{
textBox1.Text = "На 0 делить нельзя!";
}
else
{
Result = Value / Value2;
textBox1.Text = Math.Round(Result, 4).ToString();
}
break;
}
Value = 0;
}
private void button4_Click(object sender, EventArgs e)
{
Value = Convert.ToDouble(textBox1.Text);
Oper = 4;
textBox1.Text = "0";
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question