资源简介

模仿WIN7标准计算器做的,可以实现加减乘除,连加连减连乘连除连等,可以实现MS/MR/M+/M-/MC

资源截图

代码片段和文件信息

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 WCalculator
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        double num1 num2 result;
        string str opp1 opp2;
        bool eq_flag=false opp_flag=false;
        private void btnSign_Click(object sender EventArgs e)
        {
            str = txtXs.Text;
            int index = str.IndexOf(“-“);
            if (index == -1)
            {
                str = str.Insert(0 “-“);
                txtXs.Text = str;
            }
            else
            {
                str = str.Substring(1);
                txtXs.Text = str;
            }
        }//z正负号

        private void Number(object sender EventArgs e)
        {
            Button b = (Button)(sender);
            str = b.Text;
            if (txtXs.Text == “0“)
            {
                txtXs.Text = str;
            }
            else
            {
                txtXs.Text = txtXs.Text + str;
            }
        }//输入数字事件

        private void Operator1(object sender EventArgs e)//运算事件
        {
            Button b = (Button)sender;

            if (b.Text != “=“)
            {
                num1 = double.Parse(txtXs.Text);
                opp1 = b.Text;
                opp2 = ““;
                txtXs.Text = “0“;
                opp_flag = true;
            }
            else if (!opp_flag)
            {
                return;
            }
            else if(opp_flag)
            {
                if(opp2 != “=“)
                {
                    num2 = double.Parse(txtXs.Text);
                }
                switch(opp1)
                {
                    case “+“:
                        num1 = num1+ num2;
                        break;

                    case “-“:
                        num1 = num1 - num2;
                        break;

                    case “*“:
                        num1 = num1 * num2;
                        break;

                    case “/“:
                        if (num2 == 0) txtXs.Text = “除数不能为0“;
                        else num1 = num1 / num2;
                        break;
                }
                txtXs.Text = num1.ToString();
                opp2 = “=“;
            }
        }
        private void Operator2(object sender EventArgs e)
        {
            Button b = (Button)(sender);
            if (b.Text == “.“)
            {
                str = txtXs.Text;
                int index = str.IndexOf(“.“);
                if (index == -1)
                {
                    txtXs.Text = str + “.“;
                }
            }
            else if (b.Text == “←“)
            {

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

    ..A..H.     37376  2019-03-21 22:38  WCalculator\.vs\WCalculator\v15\.suo

     文件          0  2019-03-20 10:22  WCalculator\.vs\WCalculator\v15\Server\sqlite3\db.lock

     文件     585728  2019-03-20 19:24  WCalculator\.vs\WCalculator\v15\Server\sqlite3\storage.ide

     文件      32768  2019-03-21 19:29  WCalculator\.vs\WCalculator\v15\Server\sqlite3\storage.ide-shm

     文件    4120032  2019-03-20 19:58  WCalculator\.vs\WCalculator\v15\Server\sqlite3\storage.ide-wal

     文件        189  2019-03-20 10:22  WCalculator\WCalculator\App.config

     文件      16896  2019-03-20 19:58  WCalculator\WCalculator\bin\Debug\WCalculator.exe

     文件        189  2019-03-20 10:22  WCalculator\WCalculator\bin\Debug\WCalculator.exe.config

     文件      34304  2019-03-20 19:58  WCalculator\WCalculator\bin\Debug\WCalculator.pdb

     文件       4357  2019-03-20 19:59  WCalculator\WCalculator\Form1.cs

     文件       4284  2019-03-20 19:24  WCalculator\WCalculator\Form1.cs~RF25a90e5.TMP

     文件      22692  2019-03-20 11:15  WCalculator\WCalculator\Form1.Designer.cs

     文件       6015  2019-03-20 11:12  WCalculator\WCalculator\Form1.resx

     文件        831  2019-03-20 10:22  WCalculator\WCalculator\obj\Debug\DesignTimeResolveAssemblyReferences.cache

     文件       7248  2019-03-20 10:22  WCalculator\WCalculator\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件          0  2019-03-20 10:22  WCalculator\WCalculator\obj\Debug\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs

     文件          0  2019-03-20 10:22  WCalculator\WCalculator\obj\Debug\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs

     文件          0  2019-03-20 10:22  WCalculator\WCalculator\obj\Debug\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs

     文件         42  2019-03-20 10:22  WCalculator\WCalculator\obj\Debug\WCalculator.csproj.CoreCompileInputs.cache

     文件       1025  2019-03-20 11:19  WCalculator\WCalculator\obj\Debug\WCalculator.csproj.FileListAbsolute.txt

     文件       1012  2019-03-20 11:12  WCalculator\WCalculator\obj\Debug\WCalculator.csproj.GenerateResource.cache

     文件      11490  2019-03-20 10:22  WCalculator\WCalculator\obj\Debug\WCalculator.csprojAssemblyReference.cache

     文件      16896  2019-03-20 19:58  WCalculator\WCalculator\obj\Debug\WCalculator.exe

     文件        180  2019-03-20 11:12  WCalculator\WCalculator\obj\Debug\WCalculator.Form1.resources

     文件      34304  2019-03-20 19:58  WCalculator\WCalculator\obj\Debug\WCalculator.pdb

     文件        180  2019-03-20 10:38  WCalculator\WCalculator\obj\Debug\WCalculator.Properties.Resources.resources

     文件        523  2019-03-20 10:22  WCalculator\WCalculator\Program.cs

     文件       1320  2019-03-20 10:22  WCalculator\WCalculator\Properties\AssemblyInfo.cs

     文件       2835  2019-03-20 10:22  WCalculator\WCalculator\Properties\Resources.Designer.cs

     文件       5612  2019-02-03 20:39  WCalculator\WCalculator\Properties\Resources.resx

............此处省略20个文件信息

评论

共有 条评论