欢迎来到三一办公! | 帮助中心 三一办公31ppt.com(应用文档模板下载平台)
三一办公
全部分类
  • 办公文档>
  • PPT模板>
  • 建筑/施工/环境>
  • 毕业设计>
  • 工程图纸>
  • 教育教学>
  • 素材源码>
  • 生活休闲>
  • 临时分类>
  • ImageVerifierCode 换一换
    首页 三一办公 > 资源分类 > DOCX文档下载  

    c#计算器代码.docx

    • 资源ID:3060454       资源大小:37.57KB        全文页数:8页
    • 资源格式: DOCX        下载积分:6.99金币
    快捷下载 游客一键下载
    会员登录下载
    三方登录下载: 微信开放平台登录 QQ登录  
    下载资源需要6.99金币
    邮箱/手机:
    温馨提示:
    用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)
    支付方式: 支付宝    微信支付   
    验证码:   换一换

    加入VIP免费专享
     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    c#计算器代码.docx

    c#计算器代码以下控件表 控件类型 Name Text form calcForm 计算器 button button1 0 . button10 9 bDot .(小数点) 小数点按钮 bPlus +(加号) 加号按钮 bSub -(减号) 减号按钮 bMul *(乘号) 乘号按钮 bDiv /(除号) 除号按钮 bEqu =(等号) 等号按钮 bClr AC 清除按钮 textBox txtCalc (空值) 用来显示输入及输出结果 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace calculator public partial class Form1 : Form public Form1 InitializeComponent; public string a; public string b; public string num; public string op; public string result; public int i = 0; private void button1_Click(object sender, EventArgs e) if (num = "0") num = null; num = num + "7" else num = num + "7" result = num; show; public void show /在textBox1里显示数据 if (i = 0) tBshow.Text = num + "." else tBshow.Text = num; private void b1_Click(object sender, EventArgs e) if (num = "0") num = null; num = num + "1" else num = num + "1" result = num; show; private void b2_Click(object sender, EventArgs e) if (num = "0") num = null; num = num + "2" else num = num + "2" result = num; show; private void b3_Click(object sender, EventArgs e) if (num = "0") num = null; num = num + "3" else num = num + "3" result = num; show; private void b4_Click(object sender, EventArgs e) if (num = "0") num = null; num = num + "4" else num = num + "4" result = num; show; private void b5_Click(object sender, EventArgs e) if (num = "0") num = null; num = num + "5" else num = num + "5" result = num; show; private void b6_Click(object sender, EventArgs e) if (num = "0") num = null; num = num + "6" else num = num + "6" result = num; show; private void b8_Click(object sender, EventArgs e) if (num = "0") num = null; num = num + "8" else num = num + "8" result = num; show; private void b9_Click(object sender, EventArgs e) if (num = "0") num = null; num = num + "9" else num = num + "9" result = num; show; private void b0_Click(object sender, EventArgs e) if (num != "0") num = num + "0" else num = "0" result = num; show; private void bDot_Click(object sender, EventArgs e) if (i = 0) num = num + "." i = 1; private void bPlus_Click(object sender, EventArgs e) a = result; op = "+" i = 0; num = null; private void bSub_Click(object sender, EventArgs e) a = result; op = "-" i = 0; num = null; private void bMul_Click(object sender, EventArgs e) a = result; op = "*" i = 0; num = null; private void bDiv_Click(object sender, EventArgs e) a = result; op = "/" i = 0; num = null; private void result_Box /将结果显示在textBox1中 tBshow.Text = result; private void bEqu_Click(object sender, EventArgs e) b = num; double m = 0, n = 0; double r = 0; if (num = null) tBshow.Text = "0" /若直接按“=”,则显示textBox1值为0 else if (op = null) tBshow.Text = result; num = null; /若输入了第一个数但未选择运算符,默认textBox1的值为num else if (b = null) /若输入了运算符但未输入第二个数,默认两个数相同 m = double.Parse(a); n = double.Parse(a); switch (op) case "+": r = m + n; result = r.ToString; result_Box; break; case "-": r = m - n; result = r.ToString; result_Box; break; case "*": r = m * n; result = r.ToString; result_Box; break; case "/": if (n = 0) tBshow.Text = "除数不能为0" else r = m / n; result = r.ToString; result_Box; break; else /输入已完成,执行“=” m = double.Parse(a); n = double.Parse(b); switch (op) case "+": r = m + n; result = r.ToString; result_Box; break; case "-": r = m - n; result = r.ToString; result_Box; break; case "*": r = m * n; result = r.ToString; result_Box; break; case "/": if (n = 0) tBshow.Text = "除数不能为0" else r = m / n; result = r.ToString; result_Box; break; num = "0" i = 0; private void bBack_Click(object sender, EventArgs e) num = result; if (num != null) if (num.Substring(num.Length - 1, 1) != ".") if (num.Length > 1) string k; k = num; k = k.Substring(0, num.Length - 1); num = k; result = num; result_Box; else num = "0" i = 0; show; else if (num.Length > 1) string k; k = num; k = k.Substring(0, num.Length - 2); i = 0; num = k; tBshow.Text = num; result = num; else num = "0" i = 0; show; else tBshow.Text = "未输入数据" private void bClr_Click(object sender, EventArgs e) tBshow.Text = "0." num = null; op = null; i = 0; private void tBshow_TextChanged(object sender, EventArgs e)

    注意事项

    本文(c#计算器代码.docx)为本站会员(小飞机)主动上传,三一办公仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知三一办公(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    备案号:宁ICP备20000045号-2

    经营许可证:宁B2-20210002

    宁公网安备 64010402000987号

    三一办公
    收起
    展开