计算器

using System.Windows.Forms;

namespace 朱华建
{
public partial class Form1 : Form
{
public static int Count = 0;

public static int right = 0;
public Form1()
{
InitializeComponent();
}

private void RandomNum()
{

Random ran = new Random();

int a1, a2;

a1 = ran.Next(1, 101);

a2 = ran.Next(1, 101);

textBox1.Text = a1.ToString();

textBox2.Text = a2.ToString();

textBox3.Text = "";

Count++;

}
private void button4_Click(object sender, EventArgs e)
{
label1.Text = "-";

RandomNum();
}

private void button3_Click(object sender, EventArgs e)
{
label1.Text = "+";

RandomNum();
}

private void button5_Click(object sender, EventArgs e)
{
label1.Text = "*";

RandomNum();
}

private void button6_Click(object sender, EventArgs e)
{
label1.Text = "/";

RandomNum();
}

private void textBox3_KeyDown(object sender, KeyEventArgs e)
{
int m;

m = int.Parse(textBox1.Text) + int.Parse(textBox2.Text);

m = int.Parse(textBox1.Text) - int.Parse(textBox2.Text);

m = int.Parse(textBox1.Text) * int.Parse(textBox2.Text);

m = int.Parse(textBox1.Text) / int.Parse(textBox2.Text);

if (e.KeyCode == Keys.Enter)
{

if (textBox3.Text == m.ToString())

right++;

RandomNum();

}
}

private void button2_Click(object sender, EventArgs e)
{
textBox3.Enabled = false;

Form2 frm2 = new Form2();

frm2.ShowDialog();
}

private void button1_Click(object sender, EventArgs e)
{
RandomNum();
}

private void Form1_Load(object sender, EventArgs e)
{

}
}
}

代码敲出来了,可是为什么运行不了呢,查找了各种资料综合了一下但还是发现不了问题在哪。

实在是解决不了了,这样就交了都感觉怪不好意思的,本来想着不交了,但自己辛辛苦苦做到这样了,不交,自己岂不是白忙活了。

还请老师指出错误,我好做出改正,谢谢老师了。

posted on 2015-10-06 15:15  朱华建  阅读(293)  评论(3编辑  收藏  举报

导航