| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1945 人关注过本帖
标题:求教各位大神如何在这个计算器上实现连续加减
只看楼主 加入收藏
Aaron25515
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2017-9-5
收藏
 问题点数:0 回复次数: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
    {
        float a = 0;
        double r = 0;
        int smybol = 0;
        int i=-1;
        string s;
            
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text +"1";
        }

        private void num2_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text +"2";
        }

        private void button1_Click_1(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text + "4";
        }

        private void button2_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text + "5";
        }

        private void num3_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text + "3";
        }

        private void num6_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text + "6";
        }

        private void num7_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text + "7";
        }

        private void num8_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text + "8";
        }

        private void num9_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text + "9";
        }

        private void num0_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text + "0";
        }

        private void button1_Click_2(object sender, EventArgs e)
        {
            textBox1.Text =textBox1.Text+ ".";
        }

        private void button1_Click_3(object sender, EventArgs e)
        {
            i++;
            a = float.Parse(this.textBox1.Text);

            this.textBox1.Text = string.Empty;

            smybol = 1;
        }

        private void but_ch_Click(object sender, EventArgs e)
        {
            a = float.Parse(this.textBox1.Text);

            this.textBox1.Text = string.Empty;
            smybol = 4;
        }

        private void but_chh_Click(object sender, EventArgs e)
        {
            a = float.Parse(this.textBox1.Text);

            this.textBox1.Text = string.Empty;
            smybol = 3;
        }

       private void num2_MouseDown(object sender, MouseEventArgs e)
        {

        }

        private void but_jah_MouseClick(object sender, MouseEventArgs e)
        {
           
        }

        private void dh_Click(object sender, EventArgs e)
        {
            float b = float.Parse(this.textBox1.Text);
            float c = 0;
            //float g = i - b;
            //float h = o * b;
            //float j = p / b;
            //

            switch (smybol)//判断smybol为何种符号(+=1 -=2 *=3 /=4)
                          
            {
                case 1://如果smybol为一
                    c = a + b;
                    break;
                case 2:
                    c = a - b;
                    break;
                case 3:
                    c=a*b;
                    break;
                case 4:
                    c = a / b; 
               
                 break;
                     

                default:
                    break;
            }
            
            this.textBox1.Text = c.ToString();//这个文本框等于C输出
            
            //this.textBox1.Text = g.ToString();
            //this.textBox1.Text = h.ToString();
            //this.textBox1.Text = j.ToString();
        }

        private void but_jh_Click(object sender, EventArgs e)
        {
            a = float.Parse(this.textBox1.Text);

            this.textBox1.Text = string.Empty;

            smybol = 2;
        }

        private void pf_Click(object sender, EventArgs e)
        {
            r = Convert.ToDouble(this.textBox1.Text);

            this.textBox1.Text = string.Empty;

            
                    this.textBox1.Text = (r * r).ToString();

                  
                  
        }

      
    }
}
搜索更多相关主题的帖子: Text private void object sender 
2017-09-05 18:15
快速回复:求教各位大神如何在这个计算器上实现连续加减
数据加载中...
 
   



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

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