ImageVerifierCode 换一换
格式:DOCX , 页数:32 ,大小:59.86KB ,
资源ID:247417      下载积分:1 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bingdoc.com/d-247417.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(C#编写简易计算器附源代码超详细.docx)为本站会员(b****1)主动上传,冰点文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰点文库(发送邮件至service@bingdoc.com或直接QQ联系客服),我们立即给予删除!

C#编写简易计算器附源代码超详细.docx

1、C#编写简易计算器附源代码超详细超详细一、因为计算器设计的控件太多,不便使用控制台应用程序完成,所以这里使用Windows窗体应用程序,并命名为Calc,如下图所示:二、向窗体中拖入需要的控件,如下图所示:完成效果图结果显示区作者博客左边的文本框是TextBox控件,并修改其name为txtShow ,按键09为Button控件,并将其name分别修改为btn_0、btn_1、btn_2、btn_3、btn_4、btn_5、btn_6、btn_7、btn_8、btn_9;按键负数的name值修改为btn_sign,按键.的name修改为btn_dot,按键+ - * /的name值分别修改为b

2、tn_add、btn_sub、btn_mul、btn_div,按键=的name值修改为btn_equ,按键倒数的name值修改为btn_rev,按键平方的name值修改为btn_sqr,按键开方的name值修改为btn_sqrt。右边的计算器图片空间是PictureBox,作者博客控件是LinkLabel,可以不添加,以上所有控件均可按照需求添加,只保留自己需要的按钮控件和textbox控件即可。三、代码部分含解释,采用switch多分支语句编写using System;using System.Drawing;using System.Collections;using Systempone

3、ntModel;using System.Windows.Forms;using System.Data;namespace Calc/ QQ:479340056 温柔一刀C#简易计算器的实现/publicclassCalcForm : System.Windows.Forms.Form private System.Windows.Forms.Button btn_0;private System.Windows.Forms.Button btn_1;private System.Windows.Forms.Button btn_2;private System.Windows.Forms.

4、Button btn_3;private System.Windows.Forms.Button btn_4;private System.Windows.Forms.Button btn_5;private System.Windows.Forms.Button btn_6;private System.Windows.Forms.Button btn_7;private System.Windows.Forms.Button btn_8;private System.Windows.Forms.Button btn_9;private System.Windows.Forms.Button

5、 btn_add;private System.Windows.Forms.Button btn_sub;private System.Windows.Forms.Button btn_mul;private System.Windows.Forms.Button btn_div;private System.Windows.Forms.Button btn_sqrt;private System.Windows.Forms.Button btn_sign;private System.Windows.Forms.Button btn_equ;private System.Windows.Fo

6、rms.Button btn_dot;private System.Windows.Forms.Button btn_rev;private System.Windows.Forms.TextBox txtShow;private System.Windows.Forms.Button btn_sqr;privatePictureBox pictureBox1;privateLinkLabel linkLabel1;/必需的设计器变量。/private SystemponentModel.Container components = null;public CalcForm / Windows

7、 窗体设计器支持所必需的/ InitializeComponent;/ TODO: 在InitializeComponent 调用后添加任何构造函数代码/ /清理所有正在使用的资源。/protectedoverridevoid Dispose if if components.Dispose; base.Dispose; #region Windows Form Designer generated code/设计器支持所需的方法- 不要使用代码编辑器修改/此方法的内容。/privatevoid InitializeComponent SystemponentModelponentResour

8、ceManager resources = new SystemponentModelponentResourceManagertypeof;this.btn_9 = new System.Windows.Forms.Button;this.txtShow = new System.Windows.Forms.TextBox;this.btn_8 = new System.Windows.Forms.Button;this.btn_7 = new System.Windows.Forms.Button;this.btn_div = new System.Windows.Forms.Button

9、;this.btn_sqrt = new System.Windows.Forms.Button;this.btn_4 = new System.Windows.Forms.Button;this.btn_5 = new System.Windows.Forms.Button;this.btn_6 = new System.Windows.Forms.Button;this.btn_1 = new System.Windows.Forms.Button;this.btn_2 = new System.Windows.Forms.Button;this.btn_3 = new System.Wi

10、ndows.Forms.Button;this.btn_0 = new System.Windows.Forms.Button;this.btn_mul = new System.Windows.Forms.Button;this.btn_sub = new System.Windows.Forms.Button;this.btn_sign = new System.Windows.Forms.Button;this.btn_equ = new System.Windows.Forms.Button;this.btn_add = new System.Windows.Forms.Button;

11、this.btn_dot = new System.Windows.Forms.Button;this.btn_sqr = new System.Windows.Forms.Button;this.btn_rev = new System.Windows.Forms.Button;this.pictureBox1 = new System.Windows.Forms.PictureBox;this.linkLabel1 = new System.Windows.Forms.LinkLabel; .BeginInit;this.SuspendLayout;/ / btn_9/ this.btn_

12、9.BackColor = System.Drawing.SystemColors.ActiveBorder;this.btn_9.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;this.btn_9.FlatAppearance.MouseDownBackColor = System.Drawing.SystemColors.ButtonFace;this.btn_9.FlatAppearance.MouseOverBackColor = System.Drawing.Color.WhiteSmoke;this.

13、btn_9.Font = new System.Drawing.Font黑体, 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ;this.btn_9.ForeColor = System.Drawing.Color.Black;this.btn_9.Location = new System.Drawing.Point;this.btn_9.Name = btn_9;this.btn_9.Size = new System.Drawing.Size;this.btn_9.TabIndex = 0

14、;this.btn_9.Tag = 9;this.btn_9.Text = 9;this.btn_9.UseVisualStyleBackColor = false;this.btn_9.Click += new System.EventHandler;/ / txtShow/ this.txtShow.Location = new System.Drawing.Point;this.txtShow.Name = txtShow;this.txtShow.ReadOnly = true;this.txtShow.Size = new System.Drawing.Size;this.txtSh

15、ow.TabIndex = 1;this.txtShow.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;/ / btn_8/ this.btn_8.BackColor = System.Drawing.SystemColors.ActiveBorder;this.btn_8.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;this.btn_8.FlatAppearance.MouseDownBackColor = System.Drawing.

16、SystemColors.ButtonFace;this.btn_8.FlatAppearance.MouseOverBackColor = System.Drawing.Color.WhiteSmoke;this.btn_8.Font = new System.Drawing.Font黑体, 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ;this.btn_8.ForeColor = System.Drawing.Color.Black;this.btn_8.Location = new Sy

17、stem.Drawing.Point;this.btn_8.Name = btn_8;this.btn_8.Size = new System.Drawing.Size;this.btn_8.TabIndex = 2;this.btn_8.Tag = 8;this.btn_8.Text = 8;this.btn_8.UseVisualStyleBackColor = false;this.btn_8.Click += new System.EventHandler;/ / btn_7/ this.btn_7.BackColor = System.Drawing.SystemColors.Act

18、iveBorder;this.btn_7.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;this.btn_7.FlatAppearance.MouseDownBackColor = System.Drawing.SystemColors.ButtonFace;this.btn_7.FlatAppearance.MouseOverBackColor = System.Drawing.Color.WhiteSmoke;this.btn_7.Font = new System.Drawing.Font黑体, 10.5F

19、, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ;this.btn_7.ForeColor = System.Drawing.Color.Black;this.btn_7.Location = new System.Drawing.Point;this.btn_7.Name = btn_7;this.btn_7.Size = new System.Drawing.Size;this.btn_7.TabIndex = 3;this.btn_7.Tag = 7;this.btn_7.Text = 7;this.

20、btn_7.UseVisualStyleBackColor = false;this.btn_7.Click += new System.EventHandler;/ / btn_div/ this.btn_div.BackColor = System.Drawing.SystemColors.ActiveBorder;this.btn_div.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;this.btn_div.FlatAppearance.MouseDownBackColor = System.Drawin

21、g.SystemColors.ButtonFace;this.btn_div.FlatAppearance.MouseOverBackColor = System.Drawing.Color.WhiteSmoke;this.btn_div.Font = new System.Drawing.Font黑体, 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ;this.btn_div.ForeColor = System.Drawing.Color.Red;this.btn_div.Location

22、= new System.Drawing.Point;this.btn_div.Name = btn_div;this.btn_div.Size = new System.Drawing.Size;this.btn_div.TabIndex = 4;this.btn_div.Text = /;this.btn_div.UseVisualStyleBackColor = false;this.btn_div.Click += new System.EventHandler;/ / btn_sqrt/ this.btn_sqrt.BackColor = System.Drawing.SystemC

23、olors.ActiveBorder;this.btn_sqrt.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;this.btn_sqrt.FlatAppearance.MouseDownBackColor = System.Drawing.SystemColors.ButtonFace;this.btn_sqrt.FlatAppearance.MouseOverBackColor = System.Drawing.Color.WhiteSmoke;this.btn_sqrt.Font = new System.

24、Drawing.Font黑体, 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ;this.btn_sqrt.ForeColor = System.Drawing.Color.Black;this.btn_sqrt.Location = new System.Drawing.Point;this.btn_sqrt.Name = btn_sqrt;this.btn_sqrt.Size = new System.Drawing.Size;this.btn_sqrt.TabIndex = 5;this.

25、btn_sqrt.Text = 开方;this.btn_sqrt.UseVisualStyleBackColor = false;this.btn_sqrt.Click += new System.EventHandler;/ / btn_4/ this.btn_4.BackColor = System.Drawing.SystemColors.ActiveBorder;this.btn_4.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;this.btn_4.FlatAppearance.MouseDownBac

26、kColor = System.Drawing.SystemColors.ButtonFace;this.btn_4.FlatAppearance.MouseOverBackColor = System.Drawing.Color.WhiteSmoke;this.btn_4.Font = new System.Drawing.Font黑体, 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ;this.btn_4.ForeColor = System.Drawing.Color.Black;this

27、.btn_4.Location = new System.Drawing.Point;this.btn_4.Name = btn_4;this.btn_4.Size = new System.Drawing.Size;this.btn_4.TabIndex = 6;this.btn_4.Tag = 4;this.btn_4.Text = 4;this.btn_4.UseVisualStyleBackColor = false;this.btn_4.Click += new System.EventHandler;/ / btn_5/ this.btn_5.BackColor = System.

28、Drawing.SystemColors.ActiveBorder;this.btn_5.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;this.btn_5.FlatAppearance.MouseDownBackColor = System.Drawing.SystemColors.ButtonFace;this.btn_5.FlatAppearance.MouseOverBackColor = System.Drawing.Color.WhiteSmoke;this.btn_5.Font = new Syst

29、em.Drawing.Font黑体, 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ;this.btn_5.ForeColor = System.Drawing.Color.Black;this.btn_5.Location = new System.Drawing.Point;this.btn_5.Name = btn_5;this.btn_5.Size = new System.Drawing.Size;this.btn_5.TabIndex = 7;this.btn_5.Tag = 5;this.btn_5.Text = 5;this.btn_5.UseVisualStyleBackColor =

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2