计算器 四则运算

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace _四则运算
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        public static int Count = 0;
     
        public static int right = 0;

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
          
            RandomNum();
        }
        private void RandomNum()
        {
            Random ran = new Random();
            int n1, n2;
            n1 = ran.Next(1, 101);
            n2 = ran.Next(1, 101);
            textBox1.Text = n1.ToString();
            textBox2.Text = n2.ToString();
            textBox3.Text = "";
            Count++;
        }

     

      

        private void button2_Click(object sender, EventArgs e)
        {
            textBox3.Enabled = false;
            Form2 frm2 = new Form2();
            frm2.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();
        }

      
        }

别人的看不懂也不想复制,看书上修该,弄的啥也不对,只能做到这里.

posted on 2015-10-07 22:14  想不起来了  阅读(157)  评论(1编辑  收藏  举报