展开全部
你在界面中拉三个textbox和四个buttoo就可以了
//加法
private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text == "" || textBox2.Text == "")
{
MessageBox.Show("请输入两个数字");
}
else
{
double FstNum = Convert.ToDouble(textBox1.Text);
double SndNum = Convert.ToDouble(textBox2.Text);
double Sum = FstNum + SndNum;
textBox3.Text = Convert.ToString(Sum);
}
}
//减法
private void button2_Click(object sender, EventArgs e)
{
if (textBox1.Text == "" || textBox2.Text == "")
{
MessageBox.Show("请输入两个数字");
}
else
{
double FstNum = Convert.ToDouble(textBox1.Text);
double SndNum = Convert.ToDouble(textBox2.Text);
double Sum = FstNum - SndNum;
textBox3.Text = Convert.ToString(Sum);
}
}
//乘法
private void button3_Click(object sender, EventArgs e)
{
if (textBox1.Text == "" || textBox2.Text == "")
{
MessageBox.Show("请输入两个数字");
}
else
{
double FstNum = Convert.ToDouble(textBox1.Text);
double SndNum = Convert.ToDouble(textBox2.Text);
double Sum = FstNum * SndNum;
textBox3.Text = Convert.ToString(Sum);
}
}
//除法
private void button4_Click(object sender, EventArgs e)
{
if (textBox1.Text == "" || textBox2.Text == "")
{
MessageBox.Show("请输入两个数字");
}
if (Convert.ToDouble(textBox1.Text) == 0 || Convert.ToDouble(textBox2.Text) == 0)
{
MessageBox.Show("两个数字均不能为0");
}
else
{
double FstNum = Convert.ToDouble(textBox1.Text);
double SndNum = Convert.ToDouble(textBox2.Text);
double Sum = FstNum / SndNum;
textBox3.Text = Convert.ToString(Sum);
}
}
//加法
private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text == "" || textBox2.Text == "")
{
MessageBox.Show("请输入两个数字");
}
else
{
double FstNum = Convert.ToDouble(textBox1.Text);
double SndNum = Convert.ToDouble(textBox2.Text);
double Sum = FstNum + SndNum;
textBox3.Text = Convert.ToString(Sum);
}
}
//减法
private void button2_Click(object sender, EventArgs e)
{
if (textBox1.Text == "" || textBox2.Text == "")
{
MessageBox.Show("请输入两个数字");
}
else
{
double FstNum = Convert.ToDouble(textBox1.Text);
double SndNum = Convert.ToDouble(textBox2.Text);
double Sum = FstNum - SndNum;
textBox3.Text = Convert.ToString(Sum);
}
}
//乘法
private void button3_Click(object sender, EventArgs e)
{
if (textBox1.Text == "" || textBox2.Text == "")
{
MessageBox.Show("请输入两个数字");
}
else
{
double FstNum = Convert.ToDouble(textBox1.Text);
double SndNum = Convert.ToDouble(textBox2.Text);
double Sum = FstNum * SndNum;
textBox3.Text = Convert.ToString(Sum);
}
}
//除法
private void button4_Click(object sender, EventArgs e)
{
if (textBox1.Text == "" || textBox2.Text == "")
{
MessageBox.Show("请输入两个数字");
}
if (Convert.ToDouble(textBox1.Text) == 0 || Convert.ToDouble(textBox2.Text) == 0)
{
MessageBox.Show("两个数字均不能为0");
}
else
{
double FstNum = Convert.ToDouble(textBox1.Text);
double SndNum = Convert.ToDouble(textBox2.Text);
double Sum = FstNum / SndNum;
textBox3.Text = Convert.ToString(Sum);
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询