一个C#计算器源代码,不知道哪里出错了
namespace P8_3{
public partial class Form1 : Form
{
private string s;
private double x, y;
private Button btn;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
textBox1.Text = "";
label1.Text = "";
}
private void buttond_Click(object sender, EventArgs e)
{
btn = (Button)sender;
textBox1.Text = textBox1.Text+btn.Text;
}
private void buttonp_Click(object sender, EventArgs e)
{
btn = (Button)sender;
if (btn.Name != "button12")
{
x = Convert.ToDouble(textBox1.Text);
textBox1.Text = "";
s = btn.Name;
label1.Text = x.ToString();
}
else
{
if (label1.Text == "")
MessageBox.Show("输入不正确!!!", "信息提示", MessageBoxButtons.OK);
else
{
y = Convert.ToDouble(textBox1.Text);
switch (s)
{
case "button13":
textBox1.Text = (x + y).ToString();
break;
case "button14":
textBox1.Text = (x - y).ToString();
break;
case "button15":
textBox1.Text = (x * y).ToString();
break;
case "button16":
if (y == 0)
MessageBox.Show("除零错误!!!", "信息提示", MessageBoxButtons.OK);
else
textBox1.Text = (x / y).ToString();
break;
}
label1.Text = textBox1.Text;
}
}
}
}
} --------------------编程问答-------------------- 有什么 提示 报错? --------------------编程问答-------------------- 点击的时候没有反应 --------------------编程问答-------------------- 打断点看看吧,会不会是方法没有关联到Click事件上面? --------------------编程问答-------------------- 还有可能就是几种Case都没有命中吧,写一个default呢 --------------------编程问答-------------------- 如果是复制的原代码 然后放控件 估计是事件没放进去 --------------------编程问答-------------------- 楼主头像好吓人 --------------------编程问答-------------------- 好 看
补充:.NET技术 , C#