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

资源简介

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;

namespace Ex4._1_Calculator
{
    public partial class Form1 : Form
    {
        double num1=1num2num_addnum_multiply=1num_mulus=0num_divade=0result;
        string Operater;
        bool b = falseb1 = true;
        public Form1()
        {
            InitializeComponent();
        }
        public void NumClick(string myNumber)
        {
            b1 = true;
            if (textBox1.Text == “0“ || b == true)
            {
                textBox1.Text = ““;
                textBox1.Text = textBox1.Text + myNumber;
            }
            else
            {
                textBox1.Text = textBox1.Text + myNumber;
            }
            b = false;
        }
        private void Form1_Load(object sender EventArgs e)
        {
            textBox1.Text = “0“;
        }

        private void buttonZero_Click(object sender EventArgs e)
        {
            NumClick(“0“);
        }

        private void buttonOne_Click(object sender EventArgs e)
        {
            NumClick(“1“);
        }

        private void buttonTwo_Click(object sender EventArgs e)
        {
            NumClick(“2“);
        }

        private void buttonThree_Click(object sender EventArgs e)
        {
            NumClick(“3“);
        }

        private void buttonFour_Click(object sender EventArgs e)
        {
            NumClick(“4“);
        }

        private void buttonFive_Click(object sender EventArgs e)
        {
            NumClick(“5“);
        }

        private void buttonSix_Click(object sender EventArgs e)
        {
            NumClick(“6“);
        }

        private void buttonSeven_Click(object sender EventArgs e)
        {
            NumClick(“7“);
        }

        private void buttonEight_Click(object sender EventArgs e)
        {
            NumClick(“8“);
        }

        private void buttonNine_Click(object sender EventArgs e)
        {
            NumClick(“9“);
        }

        private void buttonDot_Click(object sender EventArgs e)
        {
            if (textBox1.Text.Contains(“.“)==false)
            {
                textBox1.Text = textBox1.Text + “.“;
            }
        }

        private void buttonC_Click(object sender EventArgs e)
        {
            textBox1.Text = “0“;
            num1 = 0;
            num_add = 0;
            num2 = 0;
            num_divade = 0;
            num_multiply = 0;
            num_mulus = 0;
        }

        private void buttonDivade_Click(object sender EventArgs e)
        {
            b = true; 
            if (b1 == true)
            {
                num1 = double.Parse(textBox1.Text);
                if (num_divade != 0)
                {
                    num

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

     文件        890  2013-05-04 15:15  Ex4.1 Calculator\Ex4.1 Calculator.sln

    I.A..H.      8192  2013-05-14 22:59  Ex4.1 Calculator\Ex4.1 Calculator.suo

     文件       3692  2013-05-04 15:45  Ex4.1 Calculator\Ex4.1 Calculator\Ex4.1 Calculator.csproj

     文件       5926  2013-05-09 17:45  Ex4.1 Calculator\Ex4.1 Calculator\Form1.cs

     文件      16365  2013-05-09 17:45  Ex4.1 Calculator\Ex4.1 Calculator\Form1.Designer.cs

     文件       5817  2013-05-09 17:45  Ex4.1 Calculator\Ex4.1 Calculator\Form1.resx

     文件        498  2013-05-04 15:15  Ex4.1 Calculator\Ex4.1 Calculator\Program.cs

     文件      36352  2013-05-13 19:56  Ex4.1 Calculator\Ex4.1 Calculator\bin\Debug\Ex4.1 Calculator.pdb

     文件      11600  2013-05-13 19:56  Ex4.1 Calculator\Ex4.1 Calculator\bin\Debug\Ex4.1 Calculator.vshost.exe

     文件        490  2010-03-17 22:39  Ex4.1 Calculator\Ex4.1 Calculator\bin\Debug\Ex4.1 Calculator.vshost.exe.manifest

     文件      15360  2013-05-13 19:56  Ex4.1 Calculator\Ex4.1 Calculator\bin\Debug\Ex4.1 Calculator.exe

     文件      28160  2013-05-09 17:41  Ex4.1 Calculator\Ex4.1 Calculator\bin\Release\Ex4.1 Calculator.pdb

     文件      11600  2013-05-09 17:41  Ex4.1 Calculator\Ex4.1 Calculator\bin\Release\Ex4.1 Calculator.vshost.exe

     文件        490  2010-03-17 22:39  Ex4.1 Calculator\Ex4.1 Calculator\bin\Release\Ex4.1 Calculator.vshost.exe.manifest

     文件       5359  2013-05-09 11:50  Ex4.1 Calculator\Ex4.1 Calculator\obj\x86\Debug\DesignTimeResolveAssemblyReferences.cache

     文件       6322  2013-05-13 19:56  Ex4.1 Calculator\Ex4.1 Calculator\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件       3421  2013-05-13 19:56  Ex4.1 Calculator\Ex4.1 Calculator\obj\x86\Debug\Ex4.1 Calculator.csproj.FileListAbsolute.txt

     文件       9040  2013-05-09 12:18  Ex4.1 Calculator\Ex4.1 Calculator\obj\x86\Debug\Ex4.1 Calculator.csprojResolveAssemblyReference.cache

     文件      15360  2013-05-13 19:56  Ex4.1 Calculator\Ex4.1 Calculator\obj\x86\Debug\Ex4.1 Calculator.exe

     文件      36352  2013-05-13 19:56  Ex4.1 Calculator\Ex4.1 Calculator\obj\x86\Debug\Ex4.1 Calculator.pdb

     文件        180  2013-05-13 19:56  Ex4.1 Calculator\Ex4.1 Calculator\obj\x86\Debug\Ex4._1_Calculator.Form1.resources

     文件        180  2013-05-09 08:36  Ex4.1 Calculator\Ex4.1 Calculator\obj\x86\Debug\Ex4._1_Calculator.Properties.Resources.resources

     文件        300  2013-05-09 09:36  Ex4.1 Calculator\Ex4.1 Calculator\obj\x86\Debug\GenerateResource.read.1.tlog

     文件        738  2013-05-09 09:36  Ex4.1 Calculator\Ex4.1 Calculator\obj\x86\Debug\GenerateResource.write.1.tlog

     文件        975  2013-05-13 19:56  Ex4.1 Calculator\Ex4.1 Calculator\obj\x86\Debug\Ex4.1 Calculator.csproj.GenerateResource.Cache

     文件       6308  2013-05-09 17:41  Ex4.1 Calculator\Ex4.1 Calculator\obj\x86\Release\DesignTimeResolveAssemblyReferencesInput.cache

     文件        780  2013-05-09 17:41  Ex4.1 Calculator\Ex4.1 Calculator\obj\x86\Release\Ex4.1 Calculator.csproj.FileListAbsolute.txt

     文件        975  2013-05-09 17:41  Ex4.1 Calculator\Ex4.1 Calculator\obj\x86\Release\Ex4.1 Calculator.csproj.GenerateResource.Cache

     文件      14848  2013-05-09 17:41  Ex4.1 Calculator\Ex4.1 Calculator\obj\x86\Release\Ex4.1 Calculator.exe

     文件      28160  2013-05-09 17:41  Ex4.1 Calculator\Ex4.1 Calculator\obj\x86\Release\Ex4.1 Calculator.pdb

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

评论

共有 条评论