namespace 计算器
{
public partial class Form1 : Form
{
char operChar = ' ';
float num1;
bool pointFlag, symbolFlag;
public Form1()
{
InitializeComponent();
}
public void addNum(int num)
{
if (textBox1.Text == "ERROR")
{
return;
}
if (textBox1.Text == "0" || symbolFlag)
{
textBox1.Text = num.ToString();
}
else
{
textBox1.Text += num.ToString();
}
symbolFlag = false;
}
private void button0_Click(object sender, EventArgs e)
{
addNum(0);
}
private void button1_Click(object sender, EventArgs e)
{
addNum(1);
}
private void button2_Click(object sender, EventArgs e)
{
addNum(2);
}
private void button3_Click(object sender, EventArgs e)
{
addNum(3);
}
private void button4_Click(object sender, EventArgs e)
{
addNum(4);
}
private void button5_Click(object sender, EventArgs e)
{
addNum(5);
}
private void button6_Click(object sender, EventArgs e)
{
addNum(6);
}
private void button7_Click(object sender, EventArgs e)
{
addNum(7);
}
private void button8_Click(object sender, EventArgs e)
{
addNum(8);
}
private void button9_Click(object sender, EventArgs e)
{
addNum(9);
}
private void btnPoint_Click(object sender, EventArgs e)
{
if (!pointFlag)
{
if (textBox1.Text == "0" || symbolFlag)
{
textBox1.Text = "0.";
}
else
{
textBox1.Text += ".";
}
}
pointFlag = true;
symbolFlag = false;
}