winform——计算机!

原创 2015年07月10日 18:44:57


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 WindowsFormsApplication3
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();//构造函数,初始条件
        }

        private double sum = 0;
        private string biaodashi;
        private string Preyunsuanfu;
        private bool isok = true;

     
        private void button21_Click(object sender, EventArgs e)
        {
            Button btn = (Button)sender;
            if (isok)
            {
               textBox1.Text= btn.Text;
                isok = false;
            }
            else
            {
                textBox1.Text += btn.Text;
            }
        }

        private void button8_Click(object sender, EventArgs e)
        {
            textBox1.Text = "0";
            textBox2.Text = "";
            isok = true;
            Preyunsuanfu = null;
            sum = 0;
            biaodashi = "";

        }

        private void button28_Click(object sender, EventArgs e)
        {
            Button btn = (Button)sender;
            string yunsuanfu = btn.Text;
            if (Preyunsuanfu == null)
            {
                biaodashi += textBox1.Text;
                sum = double.Parse(textBox1.Text);
            }
            else
            {
                if (!isok)
                {
                    if (Preyunsuanfu == "+")
                    {
                        sum += double.Parse(textBox1.Text);
                    }
                    if (Preyunsuanfu == "-")
                    {
                        sum -= double.Parse(textBox1.Text);
                    }
                    if (Preyunsuanfu == "*")
                    {
                        sum *= double.Parse(textBox1.Text);
                    }
                    if (Preyunsuanfu == "/")
                    {
                        sum /= double.Parse(textBox1.Text);
                    }
                    if (Preyunsuanfu == "%")
                    {
                        sum %= double.Parse(textBox1.Text);
                    }

                    biaodashi = biaodashi + Preyunsuanfu + textBox1.Text;
                    textBox1.Text = sum.ToString();
                }
            }
            textBox2.Text = biaodashi + yunsuanfu;
            Preyunsuanfu = yunsuanfu;
            isok = true;
        }

        private void button6_Click(object sender, EventArgs e)
        {
            if (!isok)
            {
                if (textBox1.Text.Length == 1)
                {
                    textBox1.Text = "0";
                    isok = true;
                }
                else
                {
                    textBox1.Text = textBox1.Text.Substring(0, textBox1.Text.Length - 1);
                }
            }
        }

        private void button27_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "0")
            {
                textBox1.Text = "0.";
            }
            if (!isok && !textBox1.Text.Contains("."))
            {
                textBox1.Text += ".";
            }
            isok = false;
        }

        private void button25_Click(object sender, EventArgs e)
        {
            textBox2.Text = "";
            if (Preyunsuanfu == "+")
            {
                sum = sum + double.Parse(textBox1.Text);
            }
            if (Preyunsuanfu == "-")
            {
                sum = sum - double.Parse(textBox1.Text);
            }
            if (Preyunsuanfu == "*")
            {
                sum = sum * double.Parse(textBox1.Text);
            }
            if (Preyunsuanfu == "/")
            {
                sum = sum / double.Parse(textBox1.Text);
            }
            if (Preyunsuanfu == "%")
            {
                sum = sum % double.Parse(textBox1.Text);
            }
            textBox1.Text = sum.ToString();
            isok = true;
            biaodashi = "";
            sum = 0;
            Preyunsuanfu = null;
        }

        private void button9_Click(object sender, EventArgs e)
        {
            if (!isok)
            {
                if (decimal.Parse(textBox1.Text) > 0)
                {
                    textBox1.Text = "-" + textBox1.Text;
                }
                else
                {
                    textBox1.Text = textBox1.Text.Substring(1);
                }
            }
        }

        private void button26_Click(object sender, EventArgs e)
        {
            if (isok)
            {
                textBox1.Text = "0";

            }
            else
            {
                textBox1.Text += "0";
            }
        }
      
    }
}

C#WinForm中实现基于角色的权限菜单--C#-程序设计-计算机学习网-育龙网

  基于角色的权限菜单功能的实现在有开发经验的程序员看来仅仅是小菜一碟,然而却让许多初学者苦不堪言。为此,我将我近期花了几天时间写的权限菜单写成文字贴上博客给初学者参考。由于自己也是一个正在努力学习...

文件读写——WinForm程序

  • 2015年05月02日 13:59
  • 673KB
  • 下载

XWinForm——XNA虚拟WinForm窗体

  • 2010年06月22日 15:44
  • 1.89MB
  • 下载

Direct2D随笔2——在C#的WinForm环境下创建Gameloop

经过大量前辈的实践证明,C#中Timer们的精度都无法达到让

Myqq——WinForm效果图

  • 2012年03月26日 17:37
  • 72KB
  • 下载

.NET学习笔记(4)——winForm开发和ADO.net

• 创建应用程序框架 – 在“文件”菜单上,指向“新建”,然后单击“项目”,选择Windows 窗体应用程序”: – 出现一个表单设计视图(Windows 窗体)。这是应用程序的用户界面。向导为新...

计算机数值试验 winform版

  • 2014年02月20日 12:27
  • 48.6MB
  • 下载

C# Winform——两个窗体之间通信!!!

c#窗体通信
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:winform——计算机!
举报原因:
原因补充:

(最多只允许输入30个字)