• 大小: 64KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-05-15
  • 语言: C#
  • 标签: C#  计算器  

资源简介

能实现正常计算器的全部功能,四则运算顺序先乘除后加减

资源截图

代码片段和文件信息

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

namespace Calculator
{
    public partial class Form1 : Form
    {
        double a = 0;
        double b = 0;
        string d;

        public Form1()
        {
            InitializeComponent();
        }

        private void timer1_Tick(object sender EventArgs e)
        {
            toolStripStatusLabel2.Text = DateTime.Now.ToString();
        }

        private void Form1_Load(object sender EventArgs e)
        {
            timer1.Start();
        }

        private void btn1_Click(object sender EventArgs e)
        {
            textBox1.Text += “1“;
        }

        private void btn2_Click(object sender EventArgs e)
        {
            textBox1.Text += “2“;
        }

        private void btn3_Click(object sender EventArgs e)
        {
            textBox1.Text += “3“;
        }

        private void btn4_Click(object sender EventArgs e)
        {
            textBox1.Text += “4“;
        }

        private void btn5_Click(object sender EventArgs e)
        {
            textBox1.Text += “5“;
        }

        private void btn6_Click(object sender EventArgs e)
        {
            textBox1.Text += “6“;
        }

        private void btn7_Click(object sender EventArgs e)
        {
            textBox1.Text += “7“;
        }

        private void btn8_Click(object sender EventArgs e)
        {          
            textBox1.Text += “8“;
        }

        private void btn9_Click(object sender EventArgs e)
        {
            
            textBox1.Text += “9“;
        }

        private void btn0_Click(object sender EventArgs e)
        {
            {
                textBox1.Text += “0“;
                if (d == “/“)
                {
                    textBox1.Clear();
                    MessageBox.Show(“除数不能为零“ “错误提示“ MessageBoxButtons.OK MessageBoxIcon.Warning);
                }
            }
        }

        private void btnPoint_Click(object sender EventArgs e)
        {
            textBox1.Text += “.“;
        }

        private void btnPlus_Click(object sender EventArgs e)
        {
            b = double.Parse(textBox1.Text);
            d = “+“;
            textBox1.Text = b + “+“;
        }

        private void btnSub_Click(object sender EventArgs e)
        {
            b = double.Parse(textBox1.Text);
            d = “-“;
            textBox1.Text = b + “-“;
        }

        private void btnMul_Click(object sender EventArgs e)
        {
            b = double.Parse(textBox1.Text);
            d = “*“;
            textBox1.Text = b + “*“;
        }

        private void btnDiv_Click(object sender EventArgs e)
        {
            b = double.Parse(tex

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-12-27 15:08  Calculator\
     目录           0  2018-12-27 15:08  Calculator\.vs\
     目录           0  2018-12-27 15:08  Calculator\.vs\Calculator\
     目录           0  2018-12-27 15:08  Calculator\.vs\Calculator\v14\
     文件       41984  2018-12-27 11:57  Calculator\.vs\Calculator\v14\.suo
     目录           0  2018-12-27 15:08  Calculator\Calculator\
     文件         997  2018-12-19 11:29  Calculator\Calculator.sln
     目录           0  2018-12-27 15:08  Calculator\Calculator\bin\
     目录           0  2018-12-27 15:08  Calculator\Calculator\bin\Debug\
     文件       17408  2018-12-27 11:54  Calculator\Calculator\bin\Debug\Calculator.exe
     文件       30208  2018-12-27 11:54  Calculator\Calculator\bin\Debug\Calculator.pdb
     文件       22688  2018-12-27 11:57  Calculator\Calculator\bin\Debug\Calculator.vshost.exe
     文件         490  2018-04-12 07:35  Calculator\Calculator\bin\Debug\Calculator.vshost.exe.manifest
     文件        3734  2018-12-19 20:37  Calculator\Calculator\Calculator.csproj
     文件        5590  2018-12-26 21:52  Calculator\Calculator\Form1.cs
     文件       19324  2018-12-26 21:51  Calculator\Calculator\Form1.Designer.cs
     文件        6212  2018-12-26 21:51  Calculator\Calculator\Form1.resx
     目录           0  2018-12-27 15:08  Calculator\Calculator\obj\
     目录           0  2018-12-27 15:08  Calculator\Calculator\obj\Debug\
     文件         770  2018-12-27 11:57  Calculator\Calculator\obj\Debug\Calculator.csproj.FileListAbsolute.txt
     文件        1012  2018-12-26 21:51  Calculator\Calculator\obj\Debug\Calculator.csproj.GenerateResource.Cache
     文件        2210  2018-12-26 20:11  Calculator\Calculator\obj\Debug\Calculator.csprojResolveAssemblyReference.cache
     文件       17408  2018-12-27 11:54  Calculator\Calculator\obj\Debug\Calculator.exe
     文件         180  2018-12-26 21:51  Calculator\Calculator\obj\Debug\Calculator.Form1.resources
     文件       30208  2018-12-27 11:54  Calculator\Calculator\obj\Debug\Calculator.pdb
     文件         180  2018-12-26 20:11  Calculator\Calculator\obj\Debug\Calculator.Properties.Resources.resources
     文件        1452  2018-12-26 16:00  Calculator\Calculator\obj\Debug\DesignTimeResolveAssemblyReferences.cache
     文件        6905  2018-12-19 11:30  Calculator\Calculator\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
     目录           0  2018-12-19 11:29  Calculator\Calculator\obj\Debug\TempPE\
     文件         491  2018-12-19 11:29  Calculator\Calculator\Program.cs
     目录           0  2018-12-27 15:08  Calculator\Calculator\Properties\
............此处省略5个文件信息

评论

共有 条评论