I have a calciulator. it works fine example enter 10-5 in textbox1 and result shown on textbox2. but i want to calculate more. example 8-5*3-1 like this. or 7-2+3 and so on.
how it will be ?
here is my code
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
float ricxvi1, pasuxi;
int datvla;
private void button2_Click(object sender, EventArgs e)
{
if (textBox1.Text == "0")
textBox1.Clear();
textBox1.Text = textBox1.Text + 7;
}
private void button1_Click(object sender, EventArgs e)
{
textBox1.Clear();
textBox1.Text = textBox1.Text + 0;
textBox2.Clear();
textBox2.Text = textBox2.Text + 0;
datvla = 0;
}
private void button6_Click(object sender, EventArgs e)
{
if (textBox1.Text == "0")
textBox1.Clear();
textBox1.Text = textBox1.Text + 4;
}
private void button17_Click(object sender, EventArgs e)
{
ricxvi1 = ricxvi1 = float.Parse(textBox1.Text);
datvla = 1;
textBox1.Text += "-";
}
private void button10_Click(object sender, EventArgs e)
{
if (textBox1.Text == "0")
textBox1.Clear();
textBox1.Text = textBox1.Text + 1;
}
private void button11_Click(object sender, EventArgs e)
{
if (textBox1.Text == "0")
textBox1.Clear();
textBox1.Text = textBox1.Text + 2;
}
private void button12_Click(object sender, EventArgs e)
{
if (textBox1.Text == "0")
textBox1.Clear();
textBox1.Text = textBox1.Text + 3;
}
private void mimateba_Click_1(object sender, EventArgs e)
{
ricxvi1 = float.Parse(textBox1.Text);
datvla = 2;
textBox1.Text += "+";
}
private void button7_Click(object sender, EventArgs e)
{
if (textBox1.Text == "0")
textBox1.Clear();
textBox1.Text = textBox1.Text + 5;
}
private void button8_Click(object sender, EventArgs e)
{
if (textBox1.Text == "0")
textBox1.Clear();
textBox1.Text = textBox1.Text + 6;
}
private void button5_Click(object sender, EventArgs e)
{
ricxvi1 = float.Parse(textBox1.Text);
datvla = 3;
textBox1.Text += "*";
}
private void button3_Click(object sender, EventArgs e)
{
if (textBox1.Text == "0")
textBox1.Clear();
textBox1.Text = textBox1.Text + 8;
}
private void button4_Click(object sender, EventArgs e)
{
if (textBox1.Text == "0")
textBox1.Clear();
textBox1.Text = textBox1.Text + 9;
}
private void button9_Click(object sender, EventArgs e)
{
ricxvi1 = float.Parse(textBox1.Text);
datvla = 4;
textBox1.Text += "/";
}
private void button14_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text + 0;
}
private void button16_Click_1(object sender, EventArgs e)
{
switch (datvla)
{
case 1:
pasuxi = ricxvi1 - float.Parse(textBox1.Text.Substring(textBox1.Text.Length - 1));
textBox2.Text = pasuxi.ToString();
break;
case 2:
pasuxi = ricxvi1 + float.Parse(textBox1.Text.Substring(textBox1.Text.Length - 1));
textBox2.Text = pasuxi.ToString();
break;
case 3:
pasuxi = ricxvi1 * float.Parse(textBox1.Text.Substring(textBox1.Text.Length - 1));
textBox2.Text = pasuxi.ToString();
break;
case 4:
pasuxi = ricxvi1 / float.Parse(textBox1.Text.Substring(textBox1.Text.Length - 1));
textBox2.Text = pasuxi.ToString();
break;
default:
break;
}
}
private void button15_Click(object sender, EventArgs e)
{
if (textBox1.Text == "0")
textBox1.Clear();
textBox1.Text = textBox1.Text + ".";
}
private void Form1_Load(object sender, EventArgs e)
{
}
}