C#简单计算器
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form11 : Form
{
public Form11()
{
InitializeComponent();
MessageBox.Show("简易计算器");
}
double a = 0; //用来记录前一个数据
int flag = 0; //用来记录是某种运算方式
private void Num(int num) //用来加载显示屏上数字的显示
{
textBox1.Text = textBox1.Text + num.ToString();
if (textBox1.Text.Length >= 2 && (textBox1.Text.Substring(0, 1) == "0" && textBox1.Text.Substring (1,1) !="."))
{ /////用来观察第一个数据是否为零或者第二个数据是否为小数点
textBox1.Text = textBox1.Text.Substring(1);////若不是则把前面的0去掉
}
}
private void button3_Click(object sender, EventArgs e)
{
Num(3);
//textBox1.Text = Convert.ToString(d - c );
}
private void button2_Click(object sender, EventArgs e)
{
Num(2);
}
private void button00_Click(object sender, EventArgs e)
{
if (textBox1.Text == " ")
{
textBox1.Text = "0.";
}
else if (textBox1.Text.IndexOf(".") >= 0)
{
MessageBox.Show(" 输入有误!"); ///已经添加过小数点
}
else
textBox1.Text = textBox1.Text + ".";
}
private void button1_Click(object sender, EventArgs e)