我是编程新手,我试图制作一个简单的计算器,但使用单选按钮作为+ - * /按钮。该表单有两个文本框供用户使用,其间有单选按钮和用于答案的文本框。此代码有什么问题:单选按钮其他如果
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
int itextBox1 = 0;
int itextBox2 = 0;
int itextBox3 = 0;
itextBox1 = Convert.ToInt32(textBox1.Text);
itextBox2 = Convert.ToInt32(textBox2.Text);
if (radioButton1.Checked)
{
itextBox3 = itextBox1 + itextBox2;
}
else if (radioButton2.Checked)
{
itextBox3 = itextBox1 - itextBox2;
}
else if (radioButton3.Checked)
{
itextBox3 = itextBox1 * itextBox2;
}
else if (radioButton4.Checked)
{
itextBox3 = itextBox1/itextBox2;
}
}//void
}//class
你不这样做对你的成绩东西,一旦你计算。你只是将它粘在函数的局部变量中。 –
为什么你使用单选按钮而不是普通的按钮?一个真正的计算器有正常的按钮... –