日期:2014-05-18  浏览次数:20901 次

c#计算器设计
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace 计算器
{
  public partial class Form1 : Form
  {
  int flag;
  string left, right;
  string op;
  public Form1()
  {
  InitializeComponent();
  }
  private void button5_Click(object sender, EventArgs e)
  {
  if (this.textBox1.Text != "0")
  this.textBox1.Text = this.textBox1.Text + Convert.ToString(0);
  }
  private void Form1_Load(object sender, EventArgs e)
  {
  this.textBox1.Text = Convert.ToString(0);
  flag = 0;
  left = "";
  right = "";
  op = "";
  }

  private void button4_Click(object sender, EventArgs e)
  {
  if (this.textBox1.Text != "0")
  this.textBox1.Text = this.textBox1.Text + Convert.ToString(1);
  else
  this.textBox1.Text = Convert.ToString(1);
  }

  private void button18_Click(object sender, EventArgs e)
  {
  if (this.textBox1.Text != "0")
  this.textBox1.Text = this.textBox1.Text + Convert.ToString(2);
  else
  this.textBox1.Text = Convert.ToString(2);
  }

  private void button19_Click(object sender, EventArgs e)
  {
  if (this.textBox1.Text != "0")
  this.textBox1.Text = this.textBox1.Text + Convert.ToString(3);
  else
  this.textBox1.Text = Convert.ToString(3);
  }

  private void button3_Click(object sender, EventArgs e)
  {
  if (this.textBox1.Text != "0")
  this.textBox1.Text = this.textBox1.Text + Convert.ToString(4);
  else
  this.textBox1.Text = Convert.ToString(4);
  }

  private void button14_Click(object sender, EventArgs e)
  {
  if (this.textBox1.Text != "0")
  this.textBox1.Text = this.textBox1.Text + Convert.ToString(5);
  else
  this.textBox1.Text = Convert.ToString(5);
  }

  private void button15_Click(object sender, EventArgs e)
  {
  if (this.textBox1.Text != "0")
  this.textBox1.Text = this.textBox1.Text + Convert.ToString(6);
  else
  this.textBox1.Text = Convert.ToString(6);
  }

  private void button2_Click(object sender, EventArgs e)
  {
  if (this.textBox1.Text != "0")
  this.textBox1.Text = this.textBox1.Text + Convert.ToString(7);
  else
  this.textBox1.Text = Convert.ToString(7);
  }

  private void button10_Click(object sender, EventArgs e)
  {
  if (this.textBox1.Text != "0")
  this.textBox1.Text = this.textBox1.Text + Convert.ToStr