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

计算器 四则运算

时间:2015-10-07 22:56:16      阅读:183      评论:0      收藏:0      [点我收藏+]

标签:

技术分享技术分享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();
        }

      
        }

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

计算器 四则运算

标签:

原文地址:http://www.cnblogs.com/yang19950425/p/4859657.html

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