预览加载中,请您耐心等待几秒...
1/10
2/10
3/10
4/10
5/10
6/10
7/10
8/10
9/10
10/10

亲,该文档总共20页,到这已经超出免费预览范围,如果喜欢就直接下载吧~

如果您无法下载资料,请参考说明:

1、部分资料下载需要金币,请确保您的账户上有足够的金币

2、已购买过的文档,再次下载不重复扣费

3、资料包下载后请先用软件解压,在使用对应软件打开

.实用文档.超详细因为计算器设计的控件太多,不便使用控制台应用程序完成,所以这里使用Windows窗体应用程序,并命名为Calc,如下列图所示:向窗体中拖入需要的控件,如下列图所示:〔完成效果图〕结果显示区〔作者博客左边的文本框〕是TextBox控件,并修改其name为txtShow,按键0~9为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值分别修改为btn_add、btn_sub、btn_mul、btn_div,按键【=】的name值修改为btn_equ,按键【倒数】的name值修改为btn_rev,按键【平方】的name值修改为btn_sqr,按键【开方】的name值修改为btn_sqrt。右边的计算器图片空间是PictureBox,作者博客控件是LinkLabel,可以不添加,以上所有控件均可按照需求添加,只保存自己需要的按钮控件和textbox控件即可。代码局部〔含解释〕,采用switch多分支语句编写usingSystem;usingSystem.Drawing;usingSystem.Collections;usingSystemponentModel;usingSystem.Windows.Forms;usingSystem.Data;namespaceCalc{///<summary>///QQ:479340056温柔一刀C#简易计算器的实现///</summary>publicclassCalcForm:System.Windows.Forms.Form{privateSystem.Windows.Forms.Buttonbtn_0;privateSystem.Windows.Forms.Buttonbtn_1;privateSystem.Windows.Forms.Buttonbtn_2;privateSystem.Windows.Forms.Buttonbtn_3;privateSystem.Windows.Forms.Buttonbtn_4;privateSystem.Windows.Forms.Buttonbtn_5;privateSystem.Windows.Forms.Buttonbtn_6;privateSystem.Windows.Forms.Buttonbtn_7;privateSystem.Windows.Forms.Buttonbtn_8;privateSystem.Windows.Forms.Buttonbtn_9;privateSystem.Windows.Forms.Buttonbtn_add;privateSystem.Windows.Forms.Buttonbtn_sub;privateSystem.Windows.Forms.Buttonbtn_mul;privateSystem.Windows.Forms.Buttonbtn_div;privateSystem.Windows.Forms.Buttonbtn_sqrt;privateSystem.Windows.Forms.Buttonbtn_sign;privateSystem.Windows.Forms.Buttonbtn_equ;privateSystem.Windows.Forms.Buttonbtn_dot;privateSystem.Windows.Forms.Buttonbtn_rev;privateSystem.Windows.Forms.TextBoxtxtShow;privateSystem.Windows.Forms.Buttonbtn_sqr;privatePictureBoxpictureBox1;privateLinkLabellinkLabel1;///<summary>///必需的设计器变量。///</summary>privateSystemponentModel.Containercomponents=null;publicCalcForm(){////Windows窗体设计器支持所必需的//InitializeComponent();////TODO:在InitializeComponent调用后添加任何构造函数代码//}///<summary>///清理所有正在使用的资源。///</summary>protectedoverridevoidDispose(booldisposing){if(disposing){if(components!=null){c