Chinaunix首页 | 论坛 | 博客
  • 博客访问: 957124
  • 博文数量: 210
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 2070
  • 用 户 组: 普通用户
  • 注册时间: 2014-11-19 21:54
文章分类

全部博文(210)

文章存档

2020年(2)

2019年(18)

2018年(27)

2017年(5)

2016年(53)

2015年(88)

2014年(17)

分类: C/C++

2015-10-17 08:47:30

1.图片




2.代码如下:

点击(此处)折叠或打开

  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;

  9. namespace FirstProgram
  10. {
  11.     public partial class Form1 : Form
  12.     {
  13.         double num1 = 0, num2 = 0;
  14.         String CaculateMethod = "";
  15.         public Form1()
  16.         {
  17.             InitializeComponent();
  18.         }

  19.         private void button1_Click(object sender, EventArgs e)
  20.         {
  21.            
  22.            
  23.         }

  24.         private void button2_Click(object sender, EventArgs e)
  25.         {
  26.             MessageBox.Show("点击了播放按钮");
  27.         }

  28.         private void NumButton1_Click(object sender, EventArgs e)
  29.         {
  30.             OutputScreen.Text = OutputScreen.Text + "1";
  31.         }

  32.         private void NumButton2_Click(object sender, EventArgs e)
  33.         {
  34.             OutputScreen.Text = OutputScreen.Text + "2";
  35.         }

  36.         private void NumButton3_Click(object sender, EventArgs e)
  37.         {
  38.             OutputScreen.Text = OutputScreen.Text + "3";
  39.         }

  40.         private void NumButton4_Click(object sender, EventArgs e)
  41.         {
  42.             OutputScreen.Text = OutputScreen.Text + "4";
  43.         }

  44.         private void NumButton5_Click(object sender, EventArgs e)
  45.         {
  46.             OutputScreen.Text = OutputScreen.Text + "5";
  47.         }

  48.         private void NumButton6_Click(object sender, EventArgs e)
  49.         {
  50.             OutputScreen.Text = OutputScreen.Text + "6";
  51.         }

  52.         private void NumButton7_Click(object sender, EventArgs e)
  53.         {
  54.             OutputScreen.Text = OutputScreen.Text + "7";
  55.         }

  56.         private void NumButton8_Click(object sender, EventArgs e)
  57.         {
  58.             OutputScreen.Text = OutputScreen.Text + "8";
  59.         }

  60.         private void NumButton9_Click(object sender, EventArgs e)
  61.         {
  62.             OutputScreen.Text = OutputScreen.Text + "9";
  63.         }

  64.         private void NumButton0_Click(object sender, EventArgs e)
  65.         {
  66.             OutputScreen.Text = OutputScreen.Text + "0";
  67.         }

  68.         private void ClearButton_Click(object sender, EventArgs e)
  69.         {
  70.             OutputScreen.Text = "";
  71.         }

  72.         private void DotButton_Click(object sender, EventArgs e)
  73.         {
  74.             if (OutputScreen.Text.Contains("."))
  75.                 return;
  76.             OutputScreen.Text = OutputScreen.Text + ".";
  77.         }

  78.         private void PlusButton_Click(object sender, EventArgs e)
  79.         {
  80.             if (OutputScreen.Text == "")
  81.                 return;
  82.             num1 = Convert.ToDouble(OutputScreen.Text);
  83.             OutputScreen.Text = "";
  84.             CaculateMethod = "+";
  85.         }

  86.         private void CaculateButton_Click(object sender, EventArgs e)
  87.         {
  88.             num2 = Convert.ToDouble(OutputScreen.Text);
  89.             if (CaculateMethod == "+")
  90.                 OutputScreen.Text = (num1 + num2).ToString();
  91.             else if (CaculateMethod == "-")
  92.                 OutputScreen.Text = (num1 - num2).ToString();
  93.             else if (CaculateMethod == "X")
  94.                 OutputScreen.Text = (num1 * num2).ToString();
  95.             else if (CaculateMethod == "/")
  96.                 OutputScreen.Text = (num1 / num2).ToString();
  97.         }

  98.         private void SubButton_Click(object sender, EventArgs e)
  99.         {
  100.             num1 = Convert.ToDouble(OutputScreen.Text);
  101.             OutputScreen.Text = "";
  102.             CaculateMethod = "-";
  103.         }

  104.         private void MultiButton_Click(object sender, EventArgs e)
  105.         {
  106.             num1 = Convert.ToDouble(OutputScreen.Text);
  107.             OutputScreen.Text = "";
  108.             CaculateMethod = "X";
  109.         }

  110.         private void DivButton_Click(object sender, EventArgs e)
  111.         {
  112.             num1 = Convert.ToDouble(OutputScreen.Text);
  113.             OutputScreen.Text = "";
  114.             CaculateMethod = "/";
  115.         }

  116.     }
  117. }


阅读(1420) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~