为了正常的体验网站,请在浏览器设置里面开启Javascript功能!

c#计算器的源代码

2011-01-19 12页 doc 46KB 24阅读

用户头像

is_922035

暂无简介

举报
c#计算器的源代码using System; using System; using System.Collections.Generic; using System.Drawing; using System.Windows.Forms; namespace windshadow14 { public partial class MainForm { int i =0; int a ; int b; int i1; long c; public static void Main(string[] args) { Application.Ena...
c#计算器的源代码
using System; using System; using System.Collections.Generic; using System.Drawing; using System.Windows.Forms; namespace windshadow14 { public partial class MainForm { int i =0; int a ; int b; int i1; long c; public static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainForm()); } public MainForm() { InitializeComponent(); } void Button10Click(object sender, System.EventArgs e) { if(textBox1.Text ==" ") { textBox1.Text =textBox1.Text+"0"; } } void Button1Click(object sender, System.EventArgs e) { textBox1.Text =textBox1.Text+"1"; if(textBox1.Text==" ") { textBox1.Text =textBox1.Text+"1"; } } void Button2Click(object sender, System.EventArgs e) { textBox1.Text =textBox1.Text+"2"; if(textBox1.Text==" ") { textBox1.Text =textBox1.Text+"2"; } } void Button3Click(object sender, System.EventArgs e) { textBox1.Text =textBox1.Text+"3"; if(textBox1.Text ==" ") { textBox1.Text =textBox1.Text+"3"; } } void Button4Click(object sender, System.EventArgs e) { textBox1.Text =textBox1.Text+"4"; if(textBox1.Text==" ") { textBox1.Text =textBox1.Text+"4"; } } void Button5Click(object sender, System.EventArgs e) { textBox1.Text =textBox1.Text+"5"; if(textBox1.Text ==" ") { textBox1.Text =textBox1.Text+"5"; } } void Button6Click(object sender, System.EventArgs e) { textBox1.Text =textBox1.Text+"6"; if(textBox1.Text==" ") { textBox1.Text =textBox1.Text+"6"; } } void Button7Click(object sender, System.EventArgs e) { textBox1.Text =textBox1.Text+"7"; if(textBox1.Text ==" ") { textBox1.Text =textBox1.Text+"7"; } } void Button8Click(object sender, System.EventArgs e) { textBox1.Text =textBox1.Text+"8"; if(textBox1.Text ==" ") { textBox1.Text =textBox1.Text+"8"; } } void Button9Click(object sender, System.EventArgs e) { textBox1.Text =textBox1.Text+"9"; if(textBox1.Text ==" ") { textBox1.Text =textBox1.Text+"9"; } } void TextBox1TextChanged(object sender, System.EventArgs e) { if(i==1||i==2||i==3||i==4) { textBox1.Text =" "; } i=0; } void Button12Click(object sender, System.EventArgs e) { i=1; a =int .Parse (textBox1.Text); i1=1; } void Button16Click(object sender, System.EventArgs e) { b=int.Parse (textBox1.Text ); textBox1.Text =" "; switch(i1) { case 1: c =a +b ; break ; case 2: c =a -b ; break; case 3: c =a *b ; break; case 4: c =a /b ; break; } textBox1.Text =c.ToString (); i=0; a=0; b=0; i1=0; } void Button13Click(object sender, System.EventArgs e) { i1=2; i=1; a =int .Parse (textBox1.Text); } void MainFormLoad(object sender, System.EventArgs e) { } void Button14Click(object sender, System.EventArgs e) { i1=3; i=3; a =int .Parse (textBox1.Text); } void Button15Click(object sender, System.EventArgs e) { i1=4; i=4; a =int .Parse (textBox1.Text); } } } 还可以这样编 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace windshadow { public partial class Form1 : Form { int a; int b; int c; int b1; public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { textBox1.Text = textBox1.Text + "1"; if (b == 1) { textBox1.Text = ""; textBox1.Text = textBox1.Text + "1"; b = 0; } } private void button2_Click(object sender, EventArgs e) { textBox1.Text = textBox1.Text + "2"; if (b == 1) { textBox1.Text = ""; textBox1.Text = textBox1.Text + "2"; b = 0; } } private void button3_Click(object sender, EventArgs e) { textBox1.Text = textBox1.Text + "3"; if (b == 1) { textBox1.Text = ""; textBox1.Text = textBox1.Text + "3"; b = 0; } } private void button4_Click(object sender, EventArgs e) { textBox1.Text = textBox1.Text + "4"; if (b == 1) { textBox1.Text = ""; textBox1.Text = textBox1.Text + "4"; b = 0; } } private void button5_Click(object sender, EventArgs e) { textBox1.Text = textBox1.Text + "5"; if (b == 1) { textBox1.Text = ""; textBox1.Text = textBox1.Text + "5"; b = 0; } } private void button6_Click(object sender, EventArgs e) { textBox1.Text = textBox1.Text + "6"; if (b == 1) { textBox1.Text = ""; textBox1.Text = textBox1.Text + "6"; b = 0; } } private void button7_Click(object sender, EventArgs e) { textBox1.Text = textBox1.Text + "7"; if (b == 1) { textBox1.Text = ""; textBox1.Text = textBox1.Text + "7"; b = 0; } } private void button8_Click(object sender, EventArgs e) { textBox1.Text = textBox1.Text + "8"; if (b == 1) { textBox1.Text = ""; textBox1.Text = textBox1.Text + "8"; b = 0; } } private void button9_Click(object sender, EventArgs e) { textBox1.Text = textBox1.Text + "9"; if (b == 1) { textBox1.Text = ""; textBox1.Text = textBox1.Text + "9"; b = 0; } } private void button11_Click(object sender, EventArgs e) { textBox1.Text = textBox1.Text + "0"; if (b == 1) { textBox1.Text = ""; textBox1.Text = textBox1.Text + "0"; b = 0; } } private void button10_Click(object sender, EventArgs e) { textBox1.Text = textBox1.Text + "."; } private void button13_Click(object sender, EventArgs e) { a = int.Parse (textBox1.Text); b = 1; b1 = 1; } private void button17_Click(object sender, EventArgs e) { long d; switch (b1) { case 1: c = int.Parse(textBox1.Text); d = a + c; textBox1.Text = ""; textBox1.Text = d.ToString(); break; case 2: c = int.Parse(textBox1.Text); d = a - c; textBox1.Text = ""; textBox1.Text = d.ToString(); break; case 3: c = int.Parse(textBox1.Text); d = a * c; textBox1.Text = ""; textBox1.Text = d.ToString(); break; case 4: c = int.Parse(textBox1.Text); d = a / c; textBox1.Text = ""; textBox1.Text = d.ToString(); break; } } private void button14_Click(object sender, EventArgs e) { a = int.Parse(textBox1.Text); b = 1; b1 = 2; } private void button15_Click(object sender, EventArgs e) { a = int.Parse(textBox1.Text); b = 1; b1 = 3; } private void button16_Click(object sender, EventArgs e) { a = int.Parse(textBox1.Text); b = 1; b1 = 4; } private void button12_Click(object sender, EventArgs e) { textBox1.Text = ""; b = 0; b1 = 0; a = 0; c = 0; } private void textBox1_TextChanged(object sender, EventArgs e) { } } } 这是退格键 void Button1Click(object sender, System.EventArgs e) { try { int a =int .Parse (textBox1.Text); a =a/10; textBox1.Text =a.ToString (); } catch { double a =double.Parse (textBox1.Text ); int b = (int)a; textBox1.Text =a.ToString (); int zz =textBox1.Text.Length ; int t = zz-1; textBox1.Text=textBox1.Text.Remove(t); } } 本程序由http://www.xrszc.com 提供,需要更多可联系我
/
本文档为【c#计算器的源代码】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。 本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。 网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。

历史搜索

    清空历史搜索