求教各位大神如何在这个计算器上实现连续加减
using System;using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
float a = 0;
double r = 0;
int smybol = 0;
int i=-1;
string s;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text +"1";
}
private void num2_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text +"2";
}
private void button1_Click_1(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text + "4";
}
private void button2_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text + "5";
}
private void num3_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text + "3";
}
private void num6_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text + "6";
}
private void num7_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text + "7";
}
private void num8_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text + "8";
}
private void num9_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text + "9";
}
private void num0_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text + "0";
}
private void button1_Click_2(object sender, EventArgs e)
{
textBox1.Text =textBox1.Text+ ".";
}
private void button1_Click_3(object sender, EventArgs e)
{
i++;
a = float.Parse(this.textBox1.Text);
this.textBox1.Text = string.Empty;
smybol = 1;
}
private void but_ch_Click(object sender, EventArgs e)
{
a = float.Parse(this.textBox1.Text);
this.textBox1.Text = string.Empty;
smybol = 4;
}
private void but_chh_Click(object sender, EventArgs e)
{
a = float.Parse(this.textBox1.Text);
this.textBox1.Text = string.Empty;
smybol = 3;
}
private void num2_MouseDown(object sender, MouseEventArgs e)
{
}
private void but_jah_MouseClick(object sender, MouseEventArgs e)
{
}
private void dh_Click(object sender, EventArgs e)
{
float b = float.Parse(this.textBox1.Text);
float c = 0;
//float g = i - b;
//float h = o * b;
//float j = p / b;
//
switch (smybol)//判断smybol为何种符号(+=1 -=2 *=3 /=4)
{
case 1://如果smybol为一
c = a + b;
break;
case 2:
c = a - b;
break;
case 3:
c=a*b;
break;
case 4:
c = a / b;
break;
default:
break;
}
this.textBox1.Text = c.ToString();//这个文本框等于C输出
//this.textBox1.Text = g.ToString();
//this.textBox1.Text = h.ToString();
//this.textBox1.Text = j.ToString();
}
private void but_jh_Click(object sender, EventArgs e)
{
a = float.Parse(this.textBox1.Text);
this.textBox1.Text = string.Empty;
smybol = 2;
}
private void pf_Click(object sender, EventArgs e)
{
r = Convert.ToDouble(this.textBox1.Text);
this.textBox1.Text = string.Empty;
this.textBox1.Text = (r * r).ToString();
}
}
}