服务器之家

服务器之家 > 正文

C#实现Winform版计算器

时间:2021-11-21 15:45     来源/作者:C#教程网

本文实例为大家分享winform版计算器的具体实现方法,供大家参考,具体内容如下

前台页面设计

C#实现Winform版计算器

后台代码实现

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
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 计算器
{
  public partial class form1 : form
  {
    double c, d;
    string m;
    public form1()
    {
      initializecomponent();
    }
 
 
 
 
    private void button2_click(object sender, eventargs e)
    {
 
 
    }
 
 
    private void button8_click(object sender, eventargs e)
    {
      textbox1.text += button8.text;
    }
 
 
    private void button1_click(object sender, eventargs e)
    {
      textbox1.text += button1.text;
    }
 
 
    private void button2_click_1(object sender, eventargs e)
    {
      textbox1.text += button2.text;
 
 
    }
 
 
    private void button3_click(object sender, eventargs e)
    {
      textbox1.text += button3.text;
    }
 
 
    private void button4_click(object sender, eventargs e)
    {
      textbox1.text += button4.text;
    }
 
 
    private void button5_click(object sender, eventargs e)
    {
      textbox1.text += button5.text;
    }
 
 
    private void button6_click(object sender, eventargs e)
    {
      textbox1.text += button6.text;
    }
 
 
    private void button7_click(object sender, eventargs e)
    {
      textbox1.text += button7.text;
 
 
    }
 
 
    private void button9_click(object sender, eventargs e)
    {
      textbox1.text += button9.text;
    }
 
 
    private void button10_click(object sender, eventargs e)
    {
      textbox1.text += button10.text;
    }
 
 
    private void button15_click(object sender, eventargs e)
    {
      d= convert.todouble(textbox1.text);
      switch (m)
      {
        case("+"):
          textbox1.text = convert.tostring(c+d);
          break;
        case ("-"):
          textbox1.text = convert.tostring(c-d);
          break;
        case ("*"):
          textbox1.text = convert.tostring(c * d);
          break;
        case ("/"):
          textbox1.text = convert.tostring(c/d);
          break;
 
 
      }
    }
 
 
    private void button11_click(object sender, eventargs e)
    {
      c = convert.todouble(textbox1.text);
      textbox1.text = "";
      m = button11.text;
    }
 
 
    private void button12_click(object sender, eventargs e)
    {
      c = convert.todouble(textbox1.text);
      textbox1.text = "";
      m = button12.text;
    }
 
 
    private void button13_click(object sender, eventargs e)
    {
      c= convert.todouble(textbox1.text);
      textbox1.text = "";
      m = button13.text;
    }
 
 
    private void button14_click(object sender, eventargs e)
    {
      c = convert.todouble(textbox1.text);
      textbox1.text = "";
      m = button14.text;
    }
 
 
    private void button16_click(object sender, eventargs e)
    {
      textbox1.text = "";
    }
  }
}

以上就是本文的全部内容,希望对大家学习c#程序设计有所帮助。

标签:

相关文章

热门资讯

yue是什么意思 网络流行语yue了是什么梗
yue是什么意思 网络流行语yue了是什么梗 2020-10-11
背刺什么意思 网络词语背刺是什么梗
背刺什么意思 网络词语背刺是什么梗 2020-05-22
2020微信伤感网名听哭了 让对方看到心疼的伤感网名大全
2020微信伤感网名听哭了 让对方看到心疼的伤感网名大全 2019-12-26
2021年耽改剧名单 2021要播出的59部耽改剧列表
2021年耽改剧名单 2021要播出的59部耽改剧列表 2021-03-05
苹果12mini价格表官网报价 iPhone12mini全版本价格汇总
苹果12mini价格表官网报价 iPhone12mini全版本价格汇总 2020-11-13
返回顶部