using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
public partial class MainForm1 : Form
{
public MainForm1()
{
InitializeComponent();
}
private double n3;
private void button1_Click(object sender, EventArgs e)
{
try
{
if (textBox1.Text != null || textBox2.Text != null)
{
double n1 = Convert.ToDouble(textBox1.Text);
double n2 = Convert.ToDouble(textBox2.Text);
switch (comboBox1.Text)
{
case "+":
n3 = n1 + n2;
break;
case "-":
n3 = n1 - n2;
break;
case "*":
n3 = n1 * n2;
break;
case "/":
{
if (n2 != 0)
{
n3 = n1 / n2;
}
else
{
textBox2.Text = "操作数2不能为0";
}
}
break;
}
textBox3.Text = n3.ToString();
}
else
{
textBox1.Text = "请输入数字";
}
}
catch { }
}
private void button2_Click(object sender, EventArgs e)
{
if (textBox1.Text != null || textBox2.Text != null || textBox3.Text != null)
{
textBox2.Text = null;
textBox1.Text = null;
textBox3.Text = null;
comboBox1.Text = null;
}
}
}
}
可以发我邮箱帮助2056234911@qq.com,或者评论,谢谢