I have to clone the calc.exe from winxp and i'm stuck.I'm new in c#.
The problem is that I don't know how to get the next number when i press " + ",I take the first number from the textbox but after that I don't know how to read the next number so I can sum them.I think I'll have to do this in the "=" button somehow...but I don't really know how
Here is the code that i wrote so far
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{//Buton pt cifre(inclusiv 0);
if (textBox1.Text.Equals("0"))
textBox1.Text = ((Button)sender).Text;
else
textBox1.Text = textBox1.Text+((Button)sender).Text;
}
private void button14_Click(object sender, EventArgs e)
{//Buton pt +/-;
String S = textBox1.Text;
textBox1.Text=null;
if (S[0].Equals('-'))
for (int i = 1; i < S.Length; i++)
textBox1.Text = textBox1.Text + S[i];
else
textBox1.Text = '-'+S;
}
private void button15_Click(object sender, EventArgs e)
{//Buton pt . ;
String S = textBox1.Text;
Boolean x = true;
for (int i = 0; i < S.Length - 1; i++)
if (S[i].Equals('.'))
x = false;
if (x)
textBox1.Text = S + '.';
}
private void button20_Click(object sender, EventArgs e)
{
}
private void button21_Click(object sender, EventArgs e)
{//Buton C ;
textBox1.Text = "0";
}
private void button23_Click(object sender, EventArgs e)
{//Buton Backspace;
String S = textBox1.Text;
textBox1.Text = null;
if (S.Length == 1)
textBox1.Text = "0";
else
for (int i = 0; i < S.Length-1; i++)
textBox1.Text = textBox1.Text+S[i];
}
private void button16_Click(object sender, EventArgs e)
{//Buton +;
int a=int.Parse(textBox1.Text);
}
}
}