| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 837 人关注过本帖
标题:简单的加法运算判断正误
取消只看楼主 加入收藏
leejiliang
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2010-11-10
结帖率:0
收藏
已结贴  问题点数:20 回复次数:0 
简单的加法运算判断正误
using System;
using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            int a, b, c, d;
            radioButton1.Enabled = true;
            radioButton2.Enabled = true;
            radioButton1.Checked = false;
            radioButton2.Checked = false;
            Random rnd = new Random();
            a = rnd.Next(99);
            b = rnd.Next(99);
            c = a + b;
            d = rnd.Next(c - 1, c + 1);
            textBox1.Text = Convert.ToString(a);
            textBox2.Text = Convert.ToString(b);
            textBox3.Text = Convert.ToString(d);
            button1.Enabled = false;
            radioButton1.Enabled = true;
            radioButton2.Enabled = true;
           label3.Text = "请选择";
             }

        private void radioButton1_CheckedChanged(object sender, EventArgs e)
        {
            int a, b, c, d;

            a = Convert.ToInt32(textBox1.Text);
            b = Convert.ToInt32(textBox2.Text);
            c = Convert.ToInt32(textBox3.Text);
            d = a + b;
            if (c == d)
            {
                label3.Text = "判断正确";
            }
            else
                label3.Text = "判断错误";
            radioButton1.Enabled = false;
            radioButton2.Enabled = false;
           button1.Enabled = true;

        }
         private void radioButton2_CheckedChanged(object sender, EventArgs e)
        {
            int a, b, c, d;

            a = Convert.ToInt32(textBox1.Text);
            b = Convert.ToInt32(textBox2.Text);
            c = Convert.ToInt32(textBox3.Text);
            d = a + b;
            if (c == d)
            {
                label3.Text = "判断错误";
            }
            else
                label3.Text = "判断正确";
            radioButton1.Enabled = false;
            radioButton2.Enabled = false;
            button1.Enabled = true;
    }
   }
  }


中间红色部分为什么要写两遍才能实现Butten和radiobutten两者的enable属性轮流在true和false之间切换!
搜索更多相关主题的帖子: 正误 加法 运算 判断 
2010-11-10 13:37
快速回复:简单的加法运算判断正误
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017043 second(s), 10 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved