版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、/添加方法public double add(double a,double c) return a+b;其余的你可以自己 写下就好了都是一样的只是符号不一样3个文本框 4个点击按钮 分别代表 + - * / 如果点击的+的按钮你在+的点击事件里面 调用这个方法就好了/添加按钮+的事件private void btnX_1_Click(object sender, EventArgs e)/textbox3 是等于的值 this.textbox3.text=add(double.parse(this.textbox1.text),double.parse(this.textbox2.text)
2、.tostring();其余的按这个方法写就好了!private void btnX_1_Click(object sender, EventArgs e) if (ttx_show.Text = 0.00) ttx_show.Text = 1; else ttx_show.Text += 1; private void btnX_2_Click(object sender, EventArgs e) if (ttx_show.Text = 0.00) ttx_show.Text = 2; else ttx_show.Text += 2; private void btnX_3_Click(o
3、bject sender, EventArgs e) if (ttx_show.Text = 0.00) ttx_show.Text = 3; else ttx_show.Text += 3; private void btnX_4_Click(object sender, EventArgs e) if (ttx_show.Text = 0.00) ttx_show.Text = 4; else ttx_show.Text += 4; private void btnX_5_Click(object sender, EventArgs e) if (ttx_show.Text = 0.00)
4、 ttx_show.Text = 5; else ttx_show.Text += 5; private void btnX_6_Click(object sender, EventArgs e) if (ttx_show.Text = 0.00) ttx_show.Text = 6; else ttx_show.Text += 6; private void btnX_7_Click(object sender, EventArgs e) if (ttx_show.Text = 0.00) ttx_show.Text = 7; else ttx_show.Text += 7; private
5、 void btnX_8_Click(object sender, EventArgs e) if (ttx_show.Text = 0.00) ttx_show.Text = 8; else ttx_show.Text += 8; private void btnX_9_Click(object sender, EventArgs e) if (ttx_show.Text = 0.00) ttx_show.Text = 9; else ttx_show.Text += 9; private void btnX_0_Click(object sender, EventArgs e) if (t
6、tx_show.Text = 0.00) ttx_show.Text = 0; else ttx_show.Text += 0; private void btnX_round_Click(object sender, EventArgs e) /小数点代码 if (ttx_show.Text = 0.00) ttx_show.Text = 0.; else ttx_show.Text += .; private void btnX_bracket_left_Click(object sender, EventArgs e) if (ttx_show.Text = 0.00) ttx_show
7、.Text = (; else ttx_show.Text += (; private void btnX_bracket_right_Click(object sender, EventArgs e) if (ttx_show.Text = 0.00) ttx_show.Text = ); else ttx_show.Text += ); #region 【退格】 private void btnX_backspace_Click(object sender, EventArgs e) ttx_show.Text = ttx_show.Text.Substring(0, ttx_show.T
8、ext.Length - 1);/退格 #endregion #region 【等号】 private void btnX_equal_Click(object sender, EventArgs e) equal_fangfa(); #endregion #region 【除号】 private void btnX_divided_Click(object sender, EventArgs e) if (ttx_show.Text != 0.00) ttx_show.Text += /; #endregion #region 【乘号】 private void btnX_multiply_
9、Click(object sender, EventArgs e) if (ttx_show.Text != 0.00) ttx_show.Text += *; #endregion #region 【减号】 private void btnX_decrease_Click(object sender, EventArgs e) if (ttx_show.Text != 0.00) ttx_show.Text += -; #endregion #region 【加号】 private void btnX_add_Click(object sender, EventArgs e) if (ttx
10、_show.Text != 0.00) ttx_show.Text += +; #endregion #region 【清零】 private void btnX_CE_Click(object sender, EventArgs e) i = 0; ttx_show.Text = i.ToString(#,#0.00); #endregion #endregion #region 【自定义方法】 private void equal_fangfa() try equal = Evaluator.EvalToDouble(ttx_show.Text);/调用四则运算类 catch (Excep
11、tion ec) MessageBox.Show(错误代码为: + ec.Message); ttx_show.Text = equal.ToString(); #endregion #region 【键盘事件】 private void ttx_show_KeyPress(object sender, KeyPressEventArgs e) if (int)e.KeyChar = (int)Keys.D1) if (ttx_show.Text = 0.00) ttx_show.Text = 1; else ttx_show.Text += 1; if (int)e.KeyChar = (i
12、nt)Keys.D2) if (ttx_show.Text = 0.00) ttx_show.Text = 2; else ttx_show.Text += 2; if (int)e.KeyChar = (int)Keys.D3) if (ttx_show.Text = 0.00) ttx_show.Text = 3; else ttx_show.Text += 3; if (int)e.KeyChar = (int)Keys.D4) if (ttx_show.Text = 0.00) ttx_show.Text = 4; else ttx_show.Text += 4; if (int)e.
13、KeyChar = (int)Keys.D5) if (ttx_show.Text = 0.00) ttx_show.Text = 5; else ttx_show.Text += 5; if (int)e.KeyChar = (int)Keys.D6) if (ttx_show.Text = 0.00) ttx_show.Text = 6; else ttx_show.Text += 6; if (int)e.KeyChar = (int)Keys.D7) if (ttx_show.Text = 0.00) ttx_show.Text = 7; else ttx_show.Text += 7
14、; if (int)e.KeyChar = (int)Keys.D8) if (ttx_show.Text = 0.00) ttx_show.Text = 8; else ttx_show.Text += 8; if (int)e.KeyChar = (int)Keys.D9) if (ttx_show.Text = 0.00) ttx_show.Text = 9; else ttx_show.Text += 9; if (int)e.KeyChar = (int)Keys.D0) if (ttx_show.Text = 0.00) ttx_show.Text = 0; else ttx_sh
15、ow.Text += 0; #region 【小键盘数字键】 if (int)e.KeyChar = (int)Keys.NumPad1) if (ttx_show.Text = 0.00) ttx_show.Text = 1; else ttx_show.Text += 1; if (int)e.KeyChar = (int)Keys.NumPad2) if (ttx_show.Text = 0.00) ttx_show.Text = 2; else ttx_show.Text += 2; if (int)e.KeyChar = (int)Keys.NumPad3) if (ttx_show
16、.Text = 0.00) ttx_show.Text = 3; else ttx_show.Text += 3; if (int)e.KeyChar = (int)Keys.NumPad4) if (ttx_show.Text = 0.00) ttx_show.Text = 4; else ttx_show.Text += 4; if (int)e.KeyChar = (int)Keys.NumPad5) if (ttx_show.Text = 0.00) ttx_show.Text = 5; else ttx_show.Text += 5; if (int)e.KeyChar = (int
17、)Keys.NumPad6) if (ttx_show.Text = 0.00) ttx_show.Text = 6; else ttx_show.Text += 6; if (int)e.KeyChar = (int)Keys.NumPad7) if (ttx_show.Text = 0.00) ttx_show.Text = 7; else ttx_show.Text += 7; if (int)e.KeyChar = (int)Keys.NumPad8) if (ttx_show.Text = 0.00) ttx_show.Text = 8; else ttx_show.Text +=
18、8; if (int)e.KeyChar = (int)Keys.NumPad9) if (ttx_show.Text = 0.00) ttx_show.Text = 9; else ttx_show.Text += 9; if (int)e.KeyChar = (int)Keys.NumPad0) if (ttx_show.Text = 0.00) ttx_show.Text = 0; else ttx_show.Text += 0; #endregion #region 【加号】 if (int)e.KeyChar = (int)Keys.Add) if (ttx_show.Text !=
19、 0.00) ttx_show.Text += +; #endregion #region 【减号】 if (int)e.KeyChar = (int)Keys.Subtract) if (ttx_show.Text != 0.00) ttx_show.Text += -; #endregion #region 【乘号】 if (int)e.KeyChar = (int)Keys.Multiply) if (ttx_show.Text != 0.00) ttx_show.Text += *; #endregion #region 【除号】 if (int)e.KeyChar = (int)Ke
20、ys.Divide) if (ttx_show.Text != 0.00) ttx_show.Text += /; #endregion #region 【小数点】 if (int)e.KeyChar = (int)Keys.Decimal)/这里有问题,按小数点没反映 /小数点代码 if (ttx_show.Text = 0.00) ttx_show.Text = 0.; else ttx_show.Text += .; #endregion #region 【求结果-回车】 if (int)e.KeyChar = (int)Keys.Enter) equal_fangfa(); #endr
21、egion #region 【退格键】 if (int)e.KeyChar = (int)Keys.Back) ttx_show.Text = ttx_show.Text.Substring(0, ttx_show.Text.Length - 1);/退格 #endregion #region 【清零】 if (int)e.KeyChar = (int)Keys.Escape) i = 0; ttx_show.Text = i.ToString(#,#0.00); #endregion #endregion #region 【菜单-复制】 private void 复制CToolStripMe
22、nuItem_Click(object sender, EventArgs e) if (ttx_show.SelectedText != ) Clipboard.SetDataObject(ttx_show.SelectedText); #endregion #region 【菜单-粘贴】 private void 粘贴VToolStripMenuItem_Click(object sender, EventArgs e) /莫看懂,拿来用 IDataObject iData = Clipboard.GetDataObject(); / Determines whether the data
23、 is in a format you can use. if (iData.GetDataPresent(DataFormats.Text) / Yes it is, so display it in a text box. ttx_show.Text = (String)iData.GetData(DataFormats.Text); #endregion 下面是四则混合计算类 class Evaluator public static int EvalToInteger(string statement) string s = EvalToString(statement); return int.Parse(s.ToString(); public static double EvalToDouble(string statement) string s = EvalToString(statement); return double.Parse(s); public static string EvalToString(string statement) object o = EvalToObject(statement); return o.ToString(); public static object EvalToObject(string statement)
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 会展服务师安全知识宣贯知识考核试卷含答案
- 质检员创新实践考核试卷含答案
- 加气混凝土大板拼装工岗前趋势考核试卷含答案
- 保健艾灸师道德测试考核试卷含答案
- 中医护理的饮食调养
- 预防肺部炎症并发症的护理措施
- 2026百度学院面试题目及答案
- 骨科护理技能考核标准
- 个案护理查房:护理质量改进措施
- 面对高血压肾病:护理评估与干预
- 2026青岛城运控股集团有限公司招聘31人考试参考题库及答案解析
- 2026年北京市海淀区初三下学期二模语文试卷和答案
- 《超龄劳动者基本权益保障暂行规定》解读课件
- 2026年2026年新版七年级下册道德与法治期末复习核心考点提纲详细版新版
- 五年级下册《道德与法治》知识点
- 2026届广西南宁市中考语文模拟预测题含解析
- 2026年广西物流职业技术学院教师招聘笔试备考试题及答案解析
- 内蒙古乌海市国创数字产业发展有限责任公司招聘笔试题库2026
- 安全生产管理及人员名单
- 广告牌的制作安装及售后服务方案
- 浮力实验说课课件
评论
0/150
提交评论