divide by zero:
private void button13_Click(object sender, EventArgs e) {
equal = true;
if (plus) {
decimal deo = Convert.ToDecimal(textBox1.Tag) + Convert.ToDecimal(textBox1.Text);
textBox1.Text = deo.ToString();
}
if (minus) {
decimal deo = Convert.ToDecimal(textBox1.Tag) - Convert.ToDecimal(textBox1.Text);
textBox1.Text = deo.ToString();
}
if (multiply) {
decimal deo = Convert.ToDecimal(textBox1.Tag) * Convert.ToDecimal(textBox1.Text);
textBox1.Text = deo.ToString();
}
if (divide) {
try
{
decimal deo = Convert.ToDecimal(textBox1.Tag) / Convert.ToDecimal(textBox1.Text);
textBox1.Text = deo.ToString();
}
catch (DivideByZeroException)
{
MessageBox.Show ("Cannot Divide by zero!")
}
}
}
and the second problem is much more complicated... You have operators type boolean, so when you declare Plus_Click, Minus_Click and so on, you have to set the others to false.
Example:
private void button11_Click(object sender, EventArgs e) {
if (textBox1.Text == "") {
return;
}
else {
plus = true;
minus = false;
multiply = false;
divide = false;
equal = false;
textBox1.Tag = textBox1.Text;
textBox1.Text = "+";
}
}
In this code I can't see any more errors, maybe it could be in different class.
I hope this helps.
-Pepin z Hane