This is going to sound a little strange, but try dropping the concept of "number1" and "number2".
Instead, use Textbox1.Text as your "current input string area" and add to it in your button click event:
private void button6_Click(object sender, EventArgs e)
{
textBox1.Text += "6";
}
Copy from TextBox1.Text to TextBox2.Text directly and ignore num1, num2 number1 and number2 completely.
In addition, I would make a small change:
Every control has a Tag property. For each of your number buttons, make the Tag that character.
1 button -> Tag == "1"
2 button -> Tag == "2"
...
Then have a single handler routine for all number buttons:
private void NumberButton_Click(object sender, EventArgs e)
{
Button b = sender as Button;
if( b != null)
{
textBox1.Text += (string) b.Tag;
}
}
This way, you don't have to change the code in ten different places to alter your button handling.
And pretty please, don't use the Visual studio default names for things!
button12
is not as obvious as
butAdd
when you come back to the code next week, and it can save a lot of time trying to work out which button does what.
[edit]Typos - OriginalGriff[/edit]