如何用C#编写简易计算器

来源:学生作业帮助网 编辑:作业帮 时间:2024/04/26 17:42:48
如何用C#编写简易计算器

如何用C#编写简易计算器
如何用C#编写简易计算器

如何用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 Group2
{
public partial class Form1 : Form
{
string s;
int i = -1;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
i++;
textBox1.Text += button1.Text;
s= textBox1.Text;
}
private void button2_Click(object sender, EventArgs e)
{
i++;
textBox1.Text += button2.Text;
s = textBox1.Text;
}
private void button3_Click(object sender, EventArgs e)
{
i++;
textBox1.Text += button3.Text;
s = textBox1.Text;

}
private void button4_Click(object sender, EventArgs e)
{
i++;
textBox1.Text += button4.Text;
s = textBox1.Text;

}
private void button5_Click(object sender, EventArgs e)
{
i++;
textBox1.Text += button5.Text;
s = textBox1.Text;

}
private void button6_Click(object sender, EventArgs e)
{
i++;
textBox1.Text += button6.Text;
s = textBox1.Text;

}
private void button7_Click(object sender, EventArgs e)
{
i++;
textBox1.Text += button7.Text;
s = textBox1.Text;

}
private void button8_Click(object sender, EventArgs e)
{
i++;
textBox1.Text += button8.Text;
s = textBox1.Text;

}
private void button9_Click(object sender, EventArgs e)
{
i++;
textBox1.Text += button9.Text;
s = textBox1.Text;

}
private void button10_Click(object sender, EventArgs e)
{
i++;
textBox1.Text += button10.Text;
s = textBox1.Text;

}
private void button11_Click(object sender, EventArgs e)
{
i++;
textBox1.Text += button11.Text;
s = textBox1.Text;

}
private void button13_Click(object sender, EventArgs e)
{
i++;
textBox1.Text += "+";
s = textBox1.Text;

}
private void button14_Click(object sender, EventArgs e)
{
i++;
textBox1.Text += "-";
s = textBox1.Text;

}
private void button15_Click(object sender, EventArgs e)
{
i++;
textBox1.Text += "*";
s = textBox1.Text;

}
private void button16_Click(object sender, EventArgs e)
{
i++;
textBox1.Text += "/";
s = textBox1.Text;

}
private void button20_Click(object sender, EventArgs e)
{
i++;
textBox1.Text += button20.Text;
s = textBox1.Text;

}

private void button21_Click(object sender, EventArgs e)
{
i++;
textBox1.Text += button21.Text;
s = textBox1.Text;

}
private void button18_Click(object sender, EventArgs e)
{
s = s.TrimEnd(s[i]);
textBox1.Text = s;
i--;
}
private void button17_Click(object sender, EventArgs e)
{
textBox1.Text = "";
}

private void button19_Click(object sender, EventArgs e)
{
Class1 Eq =new Class1() ;
textBox1.Text = Eq.size(s);
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button12_Click(object sender, EventArgs e)
{
i++;
textBox1.Text += "-";
s = textBox1.Text;
}
}
}