码迷,mamicode.com
首页 > 其他好文 > 详细

四则运算。。

时间:2015-10-05 22:03:26      阅读:175      评论:0      收藏:0      [点我收藏+]

标签:

public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        public static int Count = 0;
       
        public static int right = 0;
        public static int fault = 0;
        private void button1_Click(object sender, EventArgs e)
        {
           
          
            RandomNum();
        }
        private void RandomNum()
        {
            Random ran = new Random();
            int n1, n2;
            n1 = ran.Next(1, 10);
            n2 = ran.Next(1, 10);
            textBox1.Text = n1.ToString();
            textBox2.Text = n2.ToString();
            textBox3.Text = "";
            Count++;
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            
            {
              
                textBox3.Enabled = false;
               
                textBox3.Enabled = false;
                Form2 frm = new Form2();
                frm.ShowDialog();
            }
     
           
        }

        private void textBox3_KeyDown(object sender, KeyEventArgs e)
        {
            int sum;
            sum = int.Parse(textBox1.Text) + int.Parse(textBox2.Text);
            if (e.KeyCode == Keys.Enter)
            {
                if (textBox3.Text == sum.ToString())
                    right++;
                RandomNum();
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            textBox3.Enabled = false;
            Form2 frm2 = new Form2();
            frm2.ShowDialog();
        }

        private void button3_Click(object sender, EventArgs e)
        {
          
        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void label2_Click(object sender, EventArgs e)
        {

        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void label3_Click(object sender, EventArgs e)
        {

        }

        private void label3_Click_1(object sender, EventArgs e)
        {

        }

        private void label4_Click(object sender, EventArgs e)
        {

        }

        private void label5_Click(object sender, EventArgs e)
        {

        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {

        }
public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }

        private void Form2_Load(object sender, EventArgs e)
        {
            textBox1.Text = Form1.Count.ToString();
            textBox2.Text = Form1.right.ToString();
            textBox3.Text = ((Form1.right / (double)(Form1.Count)) * 100).ToString() + "%";
        }

        private void label1_Click(object sender, EventArgs e)
        {
            textBox1.Text = Form1.Count.ToString();
            textBox2.Text = Form1.fault.ToString();
        }

        private void label2_Click(object sender, EventArgs e)
        {

        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {

        }
    }

技术分享

虽然费了很长时间写好了,但是还是有些小毛病,可能还是我学的不够好吧,希望以后会更加好好学习,做的更完美些

四则运算。。

标签:

原文地址:http://www.cnblogs.com/gdss/p/4856309.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!