| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1147 人关注过本帖
标题:我的计算器编程试调时出了一些问题,可以帮我看看怎么改么
只看楼主 加入收藏
梨小橙
Rank: 2
等 级:论坛游民
帖 子:28
专家分:13
注 册:2013-5-14
结帖率:100%
收藏
已结贴  问题点数:60 回复次数:11 
我的计算器编程试调时出了一些问题,可以帮我看看怎么改么
帮我看看,谢谢!

[ 本帖最后由 梨小橙 于 2013-5-31 13:21 编辑 ]
搜索更多相关主题的帖子: 计算器 看看 
2013-05-31 00:21
邓士林
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
来 自:淮河河畔
等 级:贵宾
威 望:61
帖 子:2392
专家分:13384
注 册:2013-3-3
收藏
得分:12 
代码呢

Maybe
2013-05-31 01:12
梨小橙
Rank: 2
等 级:论坛游民
帖 子:28
专家分:13
注 册:2013-5-14
收藏
得分:0 
回复 2楼 邓士林
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;//文本框向右对齐
         }

         private void button17_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;

             }
         }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void button16_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 button12_Click(object sender, EventArgs e)
        {

        }

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

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

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

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

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

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

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

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

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

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

        private void button14_Click(object sender, EventArgs e)
        {
            op = "Cheng";
            num1 = Convert.ToDouble(textBox1.Text);
            textBox1.Text = "*";
            XiaoShu = false;
        }

        private void button11_Click(object sender, EventArgs e)
        {
            op = "Add";
            num1 = Convert.ToDouble(textBox1.Text);
            textBox1.Text = "+";
            XiaoShu = false;
        }

        private void button13_Click(object sender, EventArgs e)
        {
            op = "Jian";
            num1 = Convert.ToDouble(textBox1.Text);
            textBox1.Text = "-";
            XiaoShu = false;
        }

        private void button15_Click(object sender, EventArgs e)
        {
            op = "Chu";
            num1 = Convert.ToDouble(textBox1.Text);
            textBox1.Text = "/";
            XiaoShu = false;
        }

        private void button18_Click(object sender, EventArgs e)
        {
            op = "PF";
            num1 = Convert.ToDouble(textBox1.Text);
            textBox1.Text = "sqrt";
            XiaoShu = false;
        }
    }
}

一念起,万水千山;
一念灭,沧海桑田。
2013-05-31 13:24
梨小橙
Rank: 2
等 级:论坛游民
帖 子:28
专家分:13
注 册:2013-5-14
收藏
得分:0 
回复 2楼 邓士林
我明明截图放上去了,奇怪了

一念起,万水千山;
一念灭,沧海桑田。
2013-05-31 13:25
csharpluntan
Rank: 9Rank: 9Rank: 9
等 级:蜘蛛侠
威 望:7
帖 子:197
专家分:1122
注 册:2013-4-24
收藏
得分:0 
连窗体等 压缩打包传上来,没有窗体不方便

投之以桃,报之以李
2013-05-31 13:35
梨小橙
Rank: 2
等 级:论坛游民
帖 子:28
专家分:13
注 册:2013-5-14
收藏
得分:0 
回复 5楼 csharpluntan
WindowsFormsApplication1.rar (45.88 KB)

一念起,万水千山;
一念灭,沧海桑田。
2013-06-01 14:29
QJlin
Rank: 7Rank: 7Rank: 7
等 级:黑侠
威 望:3
帖 子:186
专家分:560
注 册:2013-5-18
收藏
得分:12 
2010做的,读不了···

慢慢前进走,不求一步登天,只求慢慢前进
2013-06-02 09:52
zhangjing198
Rank: 2
等 级:论坛游民
帖 子:54
专家分:76
注 册:2013-4-2
收藏
得分:12 
顶楼主
2013-06-02 12:54
csharpluntan
Rank: 9Rank: 9Rank: 9
等 级:蜘蛛侠
威 望:7
帖 子:197
专家分:1122
注 册:2013-4-24
收藏
得分:12 
好吧 你赢了 2010确实读不了

投之以桃,报之以李
2013-06-02 13:23
杰与贤3
Rank: 2
等 级:论坛游民
帖 子:11
专家分:18
注 册:2013-5-17
收藏
得分:12 
2013-06-02 22:37
快速回复:我的计算器编程试调时出了一些问题,可以帮我看看怎么改么
数据加载中...
 
   



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

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