基本信息
源码名称:C#设计简易计算器
源码大小:0.05M
文件格式:.rar
开发语言:C#
更新时间:2019-02-27
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559

本次赞助数额为: 2 元 
   源码介绍

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace _07简易计算器
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            ProShow.Text = "0";
            ResultShow.Text = "0";
            ResultShow.TextAlign = HorizontalAlignment.Right;
            
        }
        public string temp = string.Empty;
        private void ONE_Click(object sender, EventArgs e)
        {
            temp  = "1";
            ProShow.Text = temp;
            
        }

        private void TWO_Click(object sender, EventArgs e)
        {
            temp  = "2";
            ProShow.Text = temp;
 //           Calculation.Number2 = 2;
        }

        private void THREE_Click(object sender, EventArgs e)
        {
            temp  = "3";
            ProShow.Text = temp;
        }

        private void FOUR_Click(object sender, EventArgs e)
        {
            temp  = "4";
            ProShow.Text = temp;
  //          Calculation.Number1 = 4;
        }

        private void FIVE_Click(object sender, EventArgs e)
        {
            temp  = "5";
            ProShow.Text = temp;
        }

        private void SIX_Click(object sender, EventArgs e)
        {
            temp  = "6";
            ProShow.Text = temp;
        }

        private void SEVEN_Click(object sender, EventArgs e)
        {
            temp  = "7";
            ProShow.Text = temp;
        }

        private void EIGHT_Click(object sender, EventArgs e)
        {
            temp  = "8";
            ProShow.Text = temp;
        }

        private void NINE_Click(object sender, EventArgs e)
        {
            temp  = "9";
            ProShow.Text = temp;
        }

        private void ZERO_Click(object sender, EventArgs e)
        {
            temp  = "0";
            ProShow.Text = temp;
        }

        private void POINT_Click(object sender, EventArgs e)
        {
            temp  = ".";
            ProShow.Text = temp;
        }

        private void DIV_Click(object sender, EventArgs e)
        {
            temp  = "/";
            ProShow.Text = temp;
        }

        private void MUL_Click(object sender, EventArgs e)
        {
            temp  = "*";
            ProShow.Text = temp;
        }

        private void SUB_Click(object sender, EventArgs e)
        {
            temp  = "-";
            ProShow.Text = temp;
        }

        private void SUM_Click(object sender, EventArgs e)
        {
            temp  = " ";
            ProShow.Text = temp;
        }

        private void AC_Click(object sender, EventArgs e)
        {
            temp = string.Empty;
            ProShow.Text = "0";
            ResultShow.Text = "0";
            
        }

        private void EQUAL_Click(object sender, EventArgs e)
        {
            //获取数值
            string[] newStr = Calculation.GetValue(temp);
            //获取运算符
            string[] newOpt = Calculation.GetOperate(temp);
            double result = 0.0;
            for (int i = 0; i < newStr.Length-1; i  )
            {
                Calculation.Operate = newOpt[i];
                Calculation.Num1 = Convert.ToDouble(newStr[i]);
                Calculation.Num2 = Convert.ToDouble(newStr[i 1]);
                result = Calculation.Cal(Calculation.Num1, Calculation.Operate, Calculation.Num2);
                newStr[i 1] = result.ToString();
            }
            ResultShow.Text = result.ToString();


        }
    }
}