| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 650 人关注过本帖
标题:求解释,我的代码哪里出错了
取消只看楼主 加入收藏
半空的spider
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2013-4-28
结帖率:100%
收藏
已结贴  问题点数: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 Windows
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)     //数字1
        {
            textBox1.Text = textBox1.Text + button1.Text;
        }

        private void button2_Click(object sender, EventArgs e)     //数字2
        {
            textBox1.Text = textBox1.Text + button2.Text;
        }

        private void button3_Click(object sender, EventArgs e)     //数字3
        {
            textBox1.Text = textBox1.Text + button3.Text;
        }

        private void button4_Click(object sender, EventArgs e)    //数字4
        {
            textBox1.Text = textBox1.Text + button4.Text;
        }

        private void button5_Click(object sender, EventArgs e)    //数字5
        {
            textBox1.Text = textBox1.Text + button5.Text;
        }

        private void button6_Click(object sender, EventArgs e)    //数字6
        {
            textBox1.Text = textBox1.Text + button6.Text;
        }

        private void button7_Click(object sender, EventArgs e)     //数字7
        {
            textBox1.Text = textBox1.Text + button7.Text;
        }

        private void button8_Click(object sender, EventArgs e)     //数字8
        {
            textBox1.Text = textBox1.Text + button8.Text;
        }

        private void button9_Click(object sender, EventArgs e)     //数字9
        {
            textBox1.Text = textBox1.Text + button9.Text;
        }

        private void button10_Click(object sender, EventArgs e)    //数字0
        {
            textBox1.Text = textBox1.Text + button10.Text;
        }

        private void button11_Click(object sender, EventArgs e)   //加号
        {
            jisuanqi j = new jisuanqi();
            j.num1 = Convert.ToInt32(textBox1.Text);
            j.type = "+";
            textBox1.Text = "";

        }

        private void button12_Click(object sender, EventArgs e)   //减号
        {
            jisuanqi j = new jisuanqi();
            j.num1 = Convert.ToInt32(textBox1.Text);
            j.type = "-";
            textBox1.Text = "";
        }

        private void button13_Click(object sender, EventArgs e)    //乘号
        {
            jisuanqi j = new jisuanqi();
            j.num1 = Convert.ToInt32(textBox1.Text);
            j.type = "*";
            textBox1.Text = "";
        }

        private void button14_Click(object sender, EventArgs e)    //除号
        {
            jisuanqi j = new jisuanqi();
            j.num1 = Convert.ToInt32(textBox1.Text);
            j.type = "/";
            textBox1.Text = "";
        }

        private void button15_Click(object sender, EventArgs e)     //开平方
        {
            jisuanqi j = new jisuanqi();
            j.num1 = Convert.ToInt32(textBox1.Text);
            j.type = "开平方";
            textBox1.Text = "";
        }

        private void button16_Click(object sender, EventArgs e)     //等号
        {
            int n;
            jisuanqi j = new jisuanqi();
            j.num2 = Convert.ToInt32(textBox1.Text);
            if (j.type == button11.Text)
            {
                n = j.jiafa(j.num1,j.num2);
                textBox1.Text = n.ToString();
            }
           else if (j.type ==button12.Text)
            {
                if (j.num2 == 0)
                    MessageBox.Show("分母不能为零");
                else
                {
                    n = j.jianfa(j.num1, j.num2);
                    textBox1.Text = n.ToString();
                }
            }
            else if (j.type ==button13.Text)
            {
                n = j.chengfa(j.num1, j.num2);
                textBox1.Text = n.ToString();
            }
            else if (j.type ==button14.Text)
            {
                n = j.chufa(j.num1, j.num2);
                textBox1.Text = n.ToString();
            }
            else if (j.type == button15.Text)
            {
                if (j.num1 < 0)
                    MessageBox.Show("该数不能被开方");
                else
                {
                    double m = j.kaifang(j.num1);
                    textBox1.Text = m.ToString();
                }
            }
        }
    }
}
public class jisuanqi
{
    public int num1;
    public int num2;
    public string type;
    public int jiafa()
    {
        return num1 + num2;
    }
    public int jiafa(int a, int b)
    {
        this.num1 = a;
        this.num2 = b;
        return (num1 + num2);
    }
    public int jianfa()
    {
        return num1 - num2;
    }
    public int jianfa(int a, int b)
    {
        this.num1 = a;
        this.num2 = b;
        return (num1 - num2);
    }
    public int chengfa()
    {
        return num1 * num2;
    }
    public int chengfa(int a, int b)
    {
        this.num1 = a;
        this.num2 = b;
        return (num1 * num2);
    }
    public int chufa()
    {
        return num1 / num2;
    }
    public int chufa(int a, int b)
    {
         this.num1 = a;
        this.num2 = b;
        return (num1 / num2);
    }
    public double kaifang(int a)
    {
        this.num1 = a;
        return Math.Sqrt(num1);
    }
}
为什么我按等号它没有结果出来,求解释。。。。
搜索更多相关主题的帖子: void namespace Windows private public 
2013-06-01 11:02
快速回复:求解释,我的代码哪里出错了
数据加载中...
 
   



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

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