If I click on 5+5
on my calculator it will display 5+5
in my first text box (I have two of them: one for the sum and one for the result). I get this error after pressing =
I think it it because when I hover over Sum.Text
it is displaying 5+5
and I need to split it up but I do not know how.
Here is my code.
private void Addition_Click(object sender, EventArgs e)
{
dbl_FirstNumber = Convert.ToDouble(Sum.Text);
Sum.AppendText ("+");
Operation = 1;
}
private void equals_Click(object sender, EventArgs e)
{
switch (Operation)
{
case 1:
Result.Text = Convert.ToString(Convert.ToDouble(Sum.Text) + dbl_FirstNumber);
break;
case 2:
Result.Text = Convert.ToString(Convert.ToDouble(Sum.Text) - dbl_FirstNumber);
break;
case 3:
Result.Text = Convert.ToString(Convert.ToDouble(Sum.Text) * dbl_FirstNumber);
break;
case 4:
Result.Text = Convert.ToString(Convert.ToDouble(Sum.Text) / dbl_FirstNumber);
break;
}
}
}