计算器怎么进行二次计算
private string a=null;private string b=null;
private double c=0;
private string sign=null;
private bool dian=false;
public Form1()
{
InitializeComponent();
}
//跟按钮的单击事件关联的方法
private void button3_Click(object sender, EventArgs e)
{
if (a != null && a != "0")
{
a = a + "0";
}
else if (a == null)
{
a = "0";
}
textBox1.Text = a;
}
private void button1_Click(object sender, EventArgs e)
{
if (a != null && a != "0")
{
a = a + "1";
}
else if (a == null)
{
a = "1";
}
textBox1.Text = a;
}
private void button11_Click(object sender, EventArgs e)
{
if (dian == false)
{
dian = true;
if (a != null)
{
a = a + ".";
}
else
{
a = "0.";
}
textBox1.Text = a;
}
}
private void button13_Click(object sender, EventArgs e)
{
if (sign == null)
{
sign = "+";
b = a;
a = null;
dian = false;
}
}
private void button12_Click(object sender, EventArgs e)
{
if(sign =="+")
{
c = Convert.ToDouble(a) + Convert.ToDouble(b);
}
if(sign =="-")
{
c = Convert.ToDouble(b) - Convert.ToDouble(a);
}
if (sign == "*")
{
c = Convert.ToDouble(a) * Convert.ToDouble(b);
}
if (sign == "/")
{
c = Convert.ToDouble(b) / Convert.ToDouble(a);
}
textBox1.Text = Convert.ToString(c);
}
private void button9_Click(object sender, EventArgs e)
{
if (a != null && a != "0")
{
a = a + "2";
}
else if (a == null)
{
a = "2";
}
textBox1.Text = a;
}
private void button2_Click(object sender, EventArgs e)
{
if (a != null && a != "0")
{
a = a + "3";
}
else if (a == null)
{
a = "3";
}
textBox1.Text = a;
}
private void button5_Click(object sender, EventArgs e)
{
if (a != null && a != "0")
{
a = a + "4";
}
else if (a == null)
{
a = "4";
}
textBox1.Text = a;
}
private void button4_Click(object sender, EventArgs e)
{
if (a != null && a != "0")
{
a = a + "5";
}
else if (a == null)
{
a = "5";
}
textBox1.Text = a;
}
private void button10_Click(object sender, EventArgs e)
{
if (a != null && a != "0")
{
a = a + "6";
}
else if (a == null)
{
a = "6";
}
textBox1.Text = a;
}
private void button7_Click(object sender, EventArgs e)
{
if (a != null && a != "0")
{
a = a + "7";
}
else if (a == null)
{
a = "7";
}
textBox1.Text = a;
}
private void button6_Click(object sender, EventArgs e)
{
if (a != null && a != "0")
{
a = a + "8";
}
else if (a == null)
{
a = "8";
}
textBox1.Text = a;
}
private void button8_Click(object sender, EventArgs e)
{
if (a != null && a != "0")
{
a = a + "9";
}
else if (a == null)
{
a = "9";
}
textBox1.Text = a;
}
private void button14_Click(object sender, EventArgs e)
{
if (sign == null)
{
sign = "-";
b = a;
a = null;
dian = false;
}
}
private void button15_Click(object sender, EventArgs e)
{
if (sign == null)
{
sign = "*";
b = a;
a = null;
dian = false;
}
}
private void button16_Click(object sender, EventArgs e)
{
if (sign == null)
{
sign = "/";
b = a;
a = null;
dian = false;
}
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button17_Click(object sender, EventArgs e)
{
textBox1.Text = "0";
c = 0;
a = null;
b = null;
dian = false;
sign = null;
}