标题:帮忙一下,帮我完成我的计算机编程
只看楼主
梨小橙
Rank: 2
等 级:论坛游民
帖 子:28
专家分:13
注 册:2013-5-14
得分:0 
回复 8楼 lxb932979339
问题是目前暂时就会这么点

一念起,万水千山;
一念灭,沧海桑田。
2013-05-29 15:35
csharpluntan
Rank: 9Rank: 9Rank: 9
等 级:蜘蛛侠
威 望:7
帖 子:197
专家分:1122
注 册:2013-4-24
得分:20 
using System;
using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using calc;

namespace calc
{

    //1+2+3-5+235-6-
   

    public partial class Form1 : Form
    {
        bool zeroCheck = true;     //用与检查字符0的使用
        bool pointCheck = false;   //用于检查 小数点的使用
        string temp = "";          //零时用来交换数据的变量
        bool operCheck=true;         //检查运算符的使用情况
        bool btdengClick = false;        //检查等号的使用情况
        isnumber a = new isnumber();//初始化类isnum的实例;
        string str1;
        string str2;
        double fstnum;
        double secdnum;
        double resnum=double.NaN;
        public int i;                 //数组的控制变量
        public int j;

        string[] svalu=new string[99];      //保存用户输入的数值
         
        string[] soper=new string[99];    //保存用户输入的字符串

        public void init()    //初始化程序
        {
           
            btdengClick = false;
            operCheck = false;
           pointCheck = false;

            i = 0;
            fstnum = new double();
            secdnum =new double();
            resnum = double.NaN;
            str1 = null;
            str2 = null;
            Array.Clear(svalu, 0, svalu.Length);
            Array.Clear(soper, 0, svalu.Length);
        }

  
      

        public void clearNumber()//清空所有文本
        {
            print2.Text = "";
            btdengClick = false;
            pointCheck = false;
            i = 0;
            fstnum = new double();
            secdnum =new double();
            resnum = double.NaN;
            str1 = "";
            str2 = "";
            Array.Clear(svalu, 0, svalu.Length);
            Array.Clear(soper, 0, svalu.Length);

        }

        public void showNum(string num)        //显示数字的方法
        {
            if (soper[1] != null && str2 == resnum.ToString())     //如果文本框中为上次运算的结果,则再次点击按钮,清空print2的值
            {
                print2.Text = "";
                str2 = "";
            }
            if (btdengClick)
            {

                clearNumber();
            }
         
                print2.Text = Convert.ToString(Convert.ToDouble(print2.Text + num)); //字符转换为数字→在转换为字符( 去除0)
                operCheck = false;
                btdengClick = false;
                zeroCheck = false;
        }

        public void saveOper(string operName)
        {
            if (operCheck)
            {
                i = (i == 0) ? 0 : i - 1;
            }

            for (i=i; i< soper.Length; i++) //把操作符按顺序写在soper上
            {
                if (soper[0] != "")
                {
                    soper[i] = operName;
                    operCheck = true;
                 
                    break;
                  
                }
            }
        }
        /// <summary>
        /// 方法calculate.设置"+-*/"操作符
       /// </summary>
        /// <param name="calcOper"></param>
        #region calculate(string calcOper)

        public void  calculate(string calcOper)
        {
            if (btdengClick)           //如果用户输入了等号.在执行+,说明是在上一次的基础上连加的.
            {
                init();                 //初始化所有参数.只保留print2中的文本 当作是用户输入.其他参数初始化

            }
                switch (calcOper)
                {
                    case "-":
                        if (operCheck == false)
                        {
                            if (soper[0] != null) //如果有操作符,则说明是连加操作
                            {
                                saveOper("-");        //保存操作符
                                svalu[i] = Convert.ToString(Convert.ToDouble(print2.Text));
                                if (soper[2] == null)     //执行连加的赋值运算.当第三个运算符为空的时候(resnum的值为第一操作数+第二操作数),
                                {                           //当第三操作符不为空,用resnum+第三操作数.resnum=resnum+svalu
                                    switch (soper[0])
                                    {
                                        case "+":
                                            resnum = Convert.ToDouble(svalu[0]) + Convert.ToDouble(svalu[1]);

                                            break;
                                        case "-":
                                            resnum = Convert.ToDouble(svalu[0]) - Convert.ToDouble(svalu[1]);
                                            break;
                                        case "*":
                                            resnum = Convert.ToDouble(svalu[0]) * Convert.ToDouble(svalu[1]);
                                            break;
                                        case "/":
                                            resnum = Convert.ToDouble(svalu[0]) / Convert.ToDouble(svalu[1]);
                                            break;

                                    }
                                }
                                else
                                {
                                    switch (soper[i - 1])
                                    {
                                        case "+":
                                            resnum += Convert.ToDouble(svalu[i]);
                                            break;
                                        case "-":
                                            resnum -= Convert.ToDouble(svalu[i]);
                                            break;
                                        case "*":
                                            resnum *= Convert.ToDouble(svalu[i]);
                                            break;
                                        case "/":
                                            resnum /= Convert.ToDouble(svalu[i]);
                                            break;
                                    }
                                }
                                str1 = print1.Text + svalu[i];     //~~~~~~~~~~~~~~~
                                print1.Text = print1.Text + svalu[i] + soper[i];

                                print2.Text = resnum.ToString();
                                str2 = resnum.ToString();


                            }
                            else
                            {
                                saveOper("-");
                                svalu[i] = Convert.ToString(Convert.ToDouble(print2.Text));      //print2中的值给svalu数组
                                str1 = print1.Text + svalu[i];
                                print1.Text = print1.Text + svalu[i] + soper[i];
                                print2.Text = "";



                            }

                            i++;

                        }
                        else
                        {



                            saveOper("-");
                            if (svalu[0] == null)
                            {
                                svalu[0] = "0";
                                print1.Text = 0 + soper[i];
                            }
                            else
                            {
                                print1.Text = str1 + soper[i];

                            }
                  
                            i++;

                        }
                        break;
                    case "+":
                        if (operCheck == false)
                        {
                            if (soper[0] != null) //如果有操作符,则说明是连加操作
                            {
                                saveOper("+");        //保存操作符
                                svalu[i] = Convert.ToString(Convert.ToDouble(print2.Text));
                                if (soper[2] == null)     //执行连加的赋值运算.当第三个运算符为空的时候(resnum的值为第一操作数+第二操作数),
                                {                           //当第三操作符不为空,用resnum+第三操作数.resnum=resnum+svalu
                                    switch (soper[0])
                                    {
                                        case "+":
                                            resnum = Convert.ToDouble(svalu[0]) + Convert.ToDouble(svalu[1]);

                                            break;
                                        case "-":
                                            resnum = Convert.ToDouble(svalu[0]) - Convert.ToDouble(svalu[1]);
                                            break;
                                        case "*":
                                            resnum = Convert.ToDouble(svalu[0]) * Convert.ToDouble(svalu[1]);
                                            break;
                                        case "/":
                                            resnum = Convert.ToDouble(svalu[0]) / Convert.ToDouble(svalu[1]);
                                            break;

                                    }
                                }
                                else
                                {
                                    switch (soper[i - 1])
                                    {
                                        case "+":
                                            resnum += Convert.ToDouble(svalu[i]);
                                            break;
                                        case "-":
                                            resnum -= Convert.ToDouble(svalu[i]);
                                            break;
                                        case "*":
                                            resnum *= Convert.ToDouble(svalu[i]);
                                            break;
                                        case "/":
                                            resnum /= Convert.ToDouble(svalu[i]);
                                            break;
                                    }
                                }
                                str1 = print1.Text + svalu[i];     //~~~~~~~~~~~~~~~
                                print1.Text = print1.Text + svalu[i] + soper[i];

                                print2.Text = resnum.ToString();
                                str2 = resnum.ToString();


                            }
                            else
                            {
                                saveOper("+");
                                svalu[i] =Convert.ToString( Convert.ToDouble( print2.Text));         //print2中的值给svalu数组
                                str1 = print1.Text + svalu[i];
                                print1.Text = print1.Text + svalu[i] + soper[i];
                                print2.Text = "";



                            }

                            i++;

                        }
                        else
                        {



                            saveOper("+");
                            if (svalu[0] == null)//判断用户是否直接按 +-*/而不输入数字
                            {
                                svalu[0] = "0";
                                print1.Text = 0 + soper[i];
                            }
                            else
                            {
                             print1.Text =  str1 + soper[i];
 
                            }

                            i++;

                        }
                        break;
                    case "*":
                        if (operCheck == false)
                        {
                            if (soper[0] != null) //如果有操作符,则说明是连加操作
                            {
                                saveOper("*");        //保存操作符
                                svalu[i] = Convert.ToString(Convert.ToDouble(print2.Text));
                                if (soper[2] == null)     //执行连加的赋值运算.当第三个运算符为空的时候(resnum的值为第一操作数+第二操作数),
                                {                           //当第三操作符不为空,用resnum+第三操作数.resnum=resnum+svalu
                                    switch (soper[0])
                                    {
                                        case "+":
                                            resnum = Convert.ToDouble(svalu[0]) + Convert.ToDouble(svalu[1]);

                                            break;
                                        case "-":
                                            resnum = Convert.ToDouble(svalu[0]) - Convert.ToDouble(svalu[1]);
                                            break;
                                        case "*":
                                            resnum = Convert.ToDouble(svalu[0]) * Convert.ToDouble(svalu[1]);
                                            break;
                                        case "/":
                                            resnum = Convert.ToDouble(svalu[0]) / Convert.ToDouble(svalu[1]);
                                            break;

                                    }
                                }
                                else
                                {
                                    switch (soper[i - 1])
                                    {
                                        case "+":
                                            resnum += Convert.ToDouble(svalu[i]);
                                            break;
                                        case "-":
                                            resnum -= Convert.ToDouble(svalu[i]);
                                            break;
                                        case "*":
                                            resnum *= Convert.ToDouble(svalu[i]);
                                            break;
                                        case "/":
                                            resnum /= Convert.ToDouble(svalu[i]);
                                            break;
                                    }
                                }
                                str1 = print1.Text + svalu[i];     //~~~~~~~~~~~~~~~
                                print1.Text = print1.Text + svalu[i] + soper[i];

                                print2.Text = resnum.ToString();
                                str2 = resnum.ToString();


                            }
                            else
                            {
                                saveOper("*");
                                svalu[i] = Convert.ToString(Convert.ToDouble(print2.Text));        //print2中的值给svalu数组
                                str1 = print1.Text + svalu[i];
                                print1.Text = print1.Text + svalu[i] + soper[i];
                                print2.Text = "";



                            }

                            i++;

                        }
                        else
                        {



                            saveOper("*");
                            if (svalu[0] == null)//判断用户是否直接按 +-*/而不输入数字
                            {
                                svalu[0] = "0";
                                print1.Text = 0 + soper[i];
                            }
                            else
                            {
                                print1.Text = str1 + soper[i];

                            }
                            i++;

                        }
                        break;
                    case "/":
                        if (operCheck == false)
                        {
                            if (soper[0] != null) //如果有操作符,则说明是连加操作
                            {
                                saveOper("/");        //保存操作符
                                svalu[i] = Convert.ToString(Convert.ToDouble(print2.Text));
                                if (soper[2] == null)     //执行连加的赋值运算.当第三个运算符为空的时候(resnum的值为第一操作数+第二操作数),
                                {                           //当第三操作符不为空,用resnum+第三操作数.resnum=resnum+svalu
                                    switch (soper[0])
                                    {
                                        case "+":
                                            resnum = Convert.ToDouble(svalu[0]) + Convert.ToDouble(svalu[1]);

                                            break;
                                        case "-":
                                            resnum = Convert.ToDouble(svalu[0]) - Convert.ToDouble(svalu[1]);
                                            break;
                                        case "*":
                                            resnum = Convert.ToDouble(svalu[0]) * Convert.ToDouble(svalu[1]);
                                            break;
                                        case "/":
                                            resnum = Convert.ToDouble(svalu[0]) / Convert.ToDouble(svalu[1]);
                                            break;

                                    }
                                }
                                else
                                {
                                    switch (soper[i - 1])
                                    {
                                        case "+":
                                            resnum += Convert.ToDouble(svalu[i]);
                                            break;
                                        case "-":
                                            resnum -= Convert.ToDouble(svalu[i]);
                                            break;
                                        case "*":
                                            resnum *= Convert.ToDouble(svalu[i]);
                                            break;
                                        case "/":
                                            resnum /= Convert.ToDouble(svalu[i]);
                                            break;
                                    }
                                }
                                str1 = print1.Text + svalu[i];     //~~~~~~~~~~~~~~~
                                print1.Text = print1.Text + svalu[i] + soper[i];

                                print2.Text = resnum.ToString();
                                str2 = resnum.ToString();


                            }
                            else
                            {
                                saveOper("/");
                                svalu[i] = Convert.ToString(Convert.ToDouble(print2.Text));         //print2中的值给svalu数组
                                str1 = print1.Text + svalu[i];
                                print1.Text = print1.Text + svalu[i] + soper[i];
                                print2.Text = "";



                            }

                            i++;

                        }
                        else
                        {



                            saveOper("/");
                            if (svalu[0] == null)//判断用户是否直接按 +-*/而不输入数字
                            {
                                svalu[0] = "0";
                                print1.Text = 0 + soper[i];
                            }
                            else
                            {
                                print1.Text = str1 + soper[i];

                            }
                            i++;

                        }
                        break;

                }

           pointCheck = false;
           zeroCheck = true;
           
            
        }
        #endregion

        public Form1()
        {
            InitializeComponent();
        }

      

        private void bt2_Click(object sender, EventArgs e)
        {
            showNum("2");
        }

        private void bt3_Click(object sender, EventArgs e)
        {
            showNum("3");
        }

        private void bt4_Click(object sender, EventArgs e)
        {
            showNum("4");
        }

        private void bt5_Click(object sender, EventArgs e)
        {
            showNum("5");
        }

        private void bt6_Click(object sender, EventArgs e)
        {
            showNum("6");
        }

        private void bt7_Click(object sender, EventArgs e)
        {
            showNum("7");
        }

        private void bt8_Click(object sender, EventArgs e)
        {
            showNum("8");
        }

        private void bt9_Click(object sender, EventArgs e)
        {
            showNum("9");
        }

        private void bt0_Click(object sender, EventArgs e)
        {
            if (soper[1] != null && str2 == resnum.ToString())     //如果文本框中为上次运算的结果,则再次点击按钮,清空print2的值
            {
                print2.Text = "";
                str2 = "";
            }
            if (btdengClick)
            {

                clearNumber();
            }
            if (zeroCheck == false)
            {
                print2.Text = print2.Text + 0;

            }
            else
            {
                print2.Text = "0";
            }

         
            operCheck = false;
            btdengClick = false;
        }

        private void btpoint_Click(object sender, EventArgs e)
        {
            if (pointCheck == false)
            {
                if (soper[1] != null && str2 == resnum.ToString())     //如果文本框中为上次运算的结果,则再次点击按钮,清空print2的值
                {
                    print2.Text = "";
                    str2 = "";
                }
                if (btdengClick)
                {

                    clearNumber();
                    print2.Text = "0";
                }
                operCheck = false;
                btdengClick = false;
                pointCheck = true;
                zeroCheck = false;
                print2.Text += ".";
            }

        }

        

        private void btjian_Click(object sender, EventArgs e)
        {
           calculate("-");
        }

        private void btchen_Click(object sender, EventArgs e)
        {
            calculate("*");
        }

        private void btchu_Click(object sender, EventArgs e)
        {
            calculate("/");
        }
        private void btjia_Click(object sender, EventArgs e)
        {

            calculate("+");

        }
        private void bt1_Click(object sender, EventArgs e)
        {
            showNum("1");
        }

        private void btdeng_Click(object sender, EventArgs e)
        {
            if (svalu[0] != null)
            {
                if (!btdengClick) //如果btdengClick=false 则说明是不是连等
                {
                    svalu[i] = print2.Text;
                    if (svalu[i] == "") //如果第二操作数为空,则执行1+=运算 实现每次+1.
                    {
                        fstnum = Convert.ToDouble(svalu[i - 1]);
                        switch (soper[i - 1])
                        {
                            case "+":
                                if (double.IsNaN(resnum))
                                {
                                    resnum = fstnum;
                                }
                                svalu[i] = fstnum.ToString();
                                resnum += fstnum;

                                break;
                            case "-":
                                if (double.IsNaN(resnum))
                                {
                                    resnum = 0;
                                    svalu[i] = fstnum.ToString();
                                    break;

                                }
                                svalu[i] = fstnum.ToString();
                                resnum -= fstnum;
                                break;
                            case "/":

                                if (fstnum == 0) //如果第一操作数为0;值为0. 0/任何数都是0
                                {
                                    resnum = 0;
                                }
                                if (double.IsNaN(resnum)) //第一次运算结果为1
                                {
                                    resnum = 1;
                                }
                                else
                                {
                                    resnum /= fstnum;   //resnum连除
                                }
                                svalu[i] = fstnum.ToString();
                                break;
                            case "*":
                                if (double.IsNaN(resnum))
                                {
                                    resnum = fstnum;
                                }
                                svalu[i] = fstnum.ToString();
                                resnum *= fstnum;
                                break;
                        }

                        print2.Text = resnum.ToString();
                        btdengClick = true;
                    }

                    else if (soper[1] == null)        //此处当第二个运算符为空,说明是普通2元+-*/.
                    {                           //用第一个数+第二个数 赋值给resnum
                        switch (soper[i - 1])
                        {
                            case "+":
                                resnum = Convert.ToDouble(svalu[0]) + Convert.ToDouble(svalu[1]);//修改为switch case
                                break;
                            case "-":
                                resnum = Convert.ToDouble(svalu[0]) - Convert.ToDouble(svalu[1]);//修改为switch case
                                break;
                            case "*":
                                resnum = Convert.ToDouble(svalu[0]) * Convert.ToDouble(svalu[1]);//修改为switch case
                                break;
                            case "/":
                                resnum = Convert.ToDouble(svalu[0]) / Convert.ToDouble(svalu[1]);//修改为switch case
                                break;
                        }

                        print2.Text = resnum.ToString();
                        btdengClick = true;
                    }

                    else                        //连加中的等于运算 如 1+2=3=5=7
                    {
                        //  svalu[i] = print2.Text;
                        switch (soper[i - 1])
                        {
                            case "+":
                                resnum = resnum + Convert.ToDouble(svalu[i]);
                                break;
                            case "-":
                                resnum = resnum - Convert.ToDouble(svalu[i]);
                                break;
                            case "*":
                                resnum = resnum * Convert.ToDouble(svalu[i]);
                                break;
                            case "/":
                                resnum = resnum / Convert.ToDouble(svalu[i]);
                                break;

                        }

                        print2.Text = resnum.ToString();
                        btdengClick = true;

                    }
                    print1.Text = "";

                }
                else   //当btdengclick=true时执行这段.说明用户执行了2次=,执行连等功能
                {
                    switch (soper[i - 1])
                    {
                        case "+":
                            resnum = resnum + Convert.ToDouble(svalu[i]);
                            break;
                        case "-":
                            resnum = resnum - Convert.ToDouble(svalu[i]);
                            break;
                        case "*":
                            resnum = resnum * Convert.ToDouble(svalu[i]);
                            break;
                        case "/":
                            resnum = resnum / Convert.ToDouble(svalu[i]);
                            break;

                    }


                    print2.Text = resnum.ToString();

                }
                pointCheck = false;
                zeroCheck = true;
            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            print2.Text = "0";
        }

        private void button4_Click(object sender, EventArgs e)
        {

        }

        private void button3_Click(object sender, EventArgs e)
        {
            clearNumber();
            print2.Text = "0";
            print1.Text = "";
        }

        private void button15_Click(object sender, EventArgs e)
        {
            if ((print2.Text != "") && (print2.Text != "0"))
            {
                print2.Text = Convert.ToString( 0- (Convert.ToDouble(print2.Text)));
            }
        }

        private void 退出ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void 复制ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            print2.Copy();
        }

        private void 粘贴ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            print2.Paste();
        }

        private void 版本信息ToolStripMenuItem_Click(object sender, EventArgs e)
        {

            Form2 newform = new Form2();
            newform.ShowDialog();
        }

        private void button1_Click(object sender, EventArgs e)//退格键
        {
            {
                if (1 == print2.Text.Length)
                {
                    print2.Text = "0";
                }
                else
                {
                    print2.Text = print2.Text.Substring(0,print2.Text.Length - 1);
                }
            }
        }

        private void print2_TextChanged(object sender, EventArgs e)
        {

        }

    }
   
   
}

投之以桃,报之以李
2013-05-29 17:44
黄辉
Rank: 4
等 级:业余侠客
帖 子:106
专家分:255
注 册:2013-4-28
得分:0 
回复 10楼 梨小橙
冤枉啊!!!没有啊!!!

你不勇敢,谁替你坚强。。。
2013-05-29 20:34
黄辉
Rank: 4
等 级:业余侠客
帖 子:106
专家分:255
注 册:2013-4-28
得分:10 
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();
        }
        double num1;
        double num2;
        double resutl;//操作数和运行结果
        bool XiaoShu = false;//判断是否是小数
        string op;      //操作数的类型
        public void numClick(int Mynum)
        {
            if (XiaoShu)//输入小数
            {
                textBox1.Text = textBox1.Text + Mynum;
            }
            else
            {
                if (textBox1.Text == "0.") //输入整数
                {
                    textBox1.Text = Mynum + ".";//输入的是整数的第一个数
                }
                else
                {
                    textBox1.Text = textBox1.Text.Substring(0, textBox1.Text.Length - 1) + Mynum + ".";//输入的不是整数的第一个数
                }
            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            textBox1.Text = "0";
            textBox1.TextAlign = HorizontalAlignment.Right;//文本框向右对齐
        }

        //数字按0-9的单击事件

        private void btnNum0_Click(object sender, EventArgs e)
        {
            numClick(0);
        }

        private void btnNum1_Click(object sender, EventArgs e)
        {
            numClick(1);
        }

        private void btnNum2_Click(object sender, EventArgs e)
        {
            numClick(2);
        }

        private void btnNum3_Click(object sender, EventArgs e)
        {
            numClick(3);
        }

        private void btnNum4_Click(object sender, EventArgs e)
        {
            numClick(4);
        }

        private void btnNum5_Click(object sender, EventArgs e)
        {
            numClick(5);
        }

        private void btnNum6_Click(object sender, EventArgs e)
        {
            numClick(6);
        }

        private void btnNum7_Click(object sender, EventArgs e)
        {
            numClick(7);
        }

        private void btnNum8_Click(object sender, EventArgs e)
        {
            numClick(8);
        }

        private void btnNum9_Click(object sender, EventArgs e)
        {
            numClick(9);
        }

        private void btnDot_Click(object sender, EventArgs e) //编写小数点.的单击事件
        {
            XiaoShu = true;
        }

        private void btnC_Click(object sender, EventArgs e)
        {
            num1 = 0;
            num2 = 0;
            textBox1.Text = "0";
            XiaoShu = false;

        }
        //  +.-.*./.的单击事件
        private void btnAdd_Click(object sender, EventArgs e)//加的单击事件
        {
            op = "Add";
            num1 = Convert.ToDouble(textBox1 .Text );
            textBox1.Text = "+";
            XiaoShu = false;
        }

        private void btnJian_Click(object sender, EventArgs e)//减的单击事件
        {
            op = "Jian";
            num1 = Convert.ToDouble(textBox1.Text);
            textBox1.Text = "-";
            XiaoShu = false;
        }

        private void btnCheng_Click(object sender, EventArgs e)//乘的单击事件
        {
            op = "Cheng";
            num1 = Convert.ToDouble(textBox1.Text);
            textBox1.Text = "*";
            XiaoShu = false;
        }

        private void btnChu_Click(object sender, EventArgs e)//除的单击事件
        {
            op = "Chu";
            num1 = Convert.ToDouble(textBox1.Text);
            textBox1.Text = "/";
            XiaoShu = false;
        }

        private void btnPF_Click(object sender, EventArgs e)//开方的单击事件
        {
            op = "PF";
            num1 = Convert.ToDouble(textBox1.Text);
            textBox1.Text = "sqrt";
            XiaoShu = false;
        }

        private void btnSum_Click(object sender, EventArgs e)//等号的单击事件
        {
            num2 = Convert.ToDouble(textBox1 .Text );
            switch (op)
            {
                case "Add":
                    resutl = num1 + num2;
                    textBox1.Text = resutl.ToString ();//加的情况
                    break;
                case"Jian":
                    resutl =num1 - num2 ;
                    textBox1.Text = resutl.ToString ();//减的情况
                    break;
                case"Cheng":
                    resutl =num1 * num2 ;
                    textBox1.Text = resutl.ToString ();//乘的情况
                    break;
                case"Chu":
                    if (num2 == 0)
                    {
                        textBox1.Text = "被除数为0,无法整除";
                    }
                    else
                    {
                        resutl = num1 / num2;
                        textBox1.Text = resutl.ToString();//除的情况
                    }
                    break;
                default:
                    resutl = Math.Sqrt(num1);
                    textBox1.Text = resutl.ToString();//开方的情况
                    break;
                    
                           
            }
        }
    }

}

你不勇敢,谁替你坚强。。。
2013-05-29 20:36
大大大
Rank: 1
等 级:新手上路
帖 子:7
专家分:1
注 册:2013-3-16
得分:0 
怎么只有一个TextBox 事件?
不科学哦。。。。。。。。
2013-05-29 22:45
梨小橙
Rank: 2
等 级:论坛游民
帖 子:28
专家分:13
注 册:2013-5-14
得分:0 
回复 14楼 黄辉
深更半夜起来看。发现你的答案好像不对

一念起,万水千山;
一念灭,沧海桑田。
2013-05-30 01:45
梨小橙
Rank: 2
等 级:论坛游民
帖 子:28
专家分:13
注 册:2013-5-14
得分:0 
回复 12楼 csharpluntan
谢谢,我会好好努力的

一念起,万水千山;
一念灭,沧海桑田。
2013-05-30 01:46
csharpluntan
Rank: 9Rank: 9Rank: 9
等 级:蜘蛛侠
威 望:7
帖 子:197
专家分:1122
注 册:2013-4-24
得分:0 
把你的分给我就行了 别的就不用谢了!

投之以桃,报之以李
2013-05-30 09:59
黄辉
Rank: 4
等 级:业余侠客
帖 子:106
专家分:255
注 册:2013-4-28
得分:0 
回复 16楼 梨小橙
没有啊。。。我调试得了。。。啊!!!

你不勇敢,谁替你坚强。。。
2013-05-30 11:53
黄辉
Rank: 4
等 级:业余侠客
帖 子:106
专家分:255
注 册:2013-4-28
得分:0 
回复 15楼 大大大
怎么说???

你不勇敢,谁替你坚强。。。
2013-05-30 11:54



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-412406-1-1.html




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

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