四则运算中 赋值问题
using System;using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace 四则运算
{
public partial class 四则运算 : Form
{
public 四则运算()
{
InitializeComponent();
}
int a ;
int b ;
int cj = 0;
int sum = 0;
Random myran = new Random();
public void chuti()
{
number1.Text = a.ToString();
number2.Text = b.ToString();
sum = a + b;
}
private void button1_Click(object sender, EventArgs e)
{
label2.Text = "+";
chuti();
}
private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
a = myran.Next(10);
b = myran.Next(10);
}
private void radioButton2_CheckedChanged(object sender, EventArgs e)
{
a = myran.Next(100);
b = myran.Next(100);
}
private void radioButton3_CheckedChanged(object sender, EventArgs e)
{
a = myran.Next(1000);
b = myran.Next(1000);
}
private void radioButton4_CheckedChanged(object sender, EventArgs e)
{
a = myran.Next(10000);
b = myran.Next(10000);
}
private void button2_Click(object sender, EventArgs e)
{
label2.Text = "-";
// chuti();
}
private void button3_Click(object sender, EventArgs e)
{
label2.Text = "*";
//chuti();
}
private void button4_Click(object sender, EventArgs e)
{
label2.Text = "/";
//chuti();
}
private void textBox1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyValue == 13)
{
if (textBox1.Text.ToString() == sum.ToString())
{
cj = cj + 1;
zhoncj.Text ="总成绩:"+ cj.ToString();
textBox1.Text = "";
chuti();
}
else
{
MessageBox.Show("答案是错误的!");
textBox1.Text = "";
}
}
}
private void 四则运算_Load(object sender, EventArgs e)
{
//chuti();
}
}
}
运行后 不能够赋值 这个是为什么????