自己写了个简易的计算器程序,有兴趣的看下
很简易的一个计算器,没什么技术含量~ --------------------编程问答-------------------- 加油 --------------------编程问答-------------------- 加油。 --------------------编程问答-------------------- 可以模仿windows自带的计算器写一个 --------------------编程问答-------------------- http://download.csdn.net/detail/wujianfei0428/4881866
贴个下载链接~ --------------------编程问答-------------------- 加油哦~~ --------------------编程问答-------------------- 除 --------------------编程问答-------------------- 有这个想法 --------------------编程问答-------------------- 谢谢,同加~ --------------------编程问答-------------------- 我这有好多计算器版本。哎不算啥 --------------------编程问答-------------------- 贵在坚持 加油 --------------------编程问答-------------------- 自己玩玩的,开心就好了~ --------------------编程问答-------------------- 不错顶一下,希望下次的版本可以多加一些功能 --------------------编程问答-------------------- 话说....代码你也不发 运行程序也木有 就贴个图上来做什么 --------------------编程问答-------------------- 其实4L也是我... --------------------编程问答-------------------- 帮顶,从简单做起。 --------------------编程问答-------------------- 计算器要想写到无Bug的程度, 也非常不容易. --------------------编程问答-------------------- 是的,我的这个很简易的,bug很多,比如按等于计算完了后再输数据,没清空tb里面的值。 --------------------编程问答-------------------- 看来, 你离考虑超过Int甚至Double边界的时候还有段距离呢...... --------------------编程问答-------------------- 除 --------------------编程问答-------------------- --------------------编程问答-------------------- 加油哈!!! --------------------编程问答-------------------- 这个,新人练手啊,但是功能太少了啊 --------------------编程问答-------------------- --------------------编程问答--------------------
--------------------编程问答-------------------- 除 --------------------编程问答-------------------- 加油。来看看,收藏了。呵呵。 --------------------编程问答-------------------- 你让我们看什么呀,源码呢 --------------------编程问答--------------------
呵呵。其实如果新手了不错了。。支持一个 --------------------编程问答-------------------- --------------------编程问答-------------------- times new roman,不错。。 --------------------编程问答-------------------- 除 --------------------编程问答-------------------- 楼主可以的 --------------------编程问答-------------------- 发个图来,有毛用。不是说共赏的嘛。。不过,, --------------------编程问答-------------------- 看看,路过,我是新手 --------------------编程问答-------------------- 可以交流一下经验 我也写过。 楼主贴出源码.. --------------------编程问答-------------------- --------------------编程问答-------------------- 我只知道计算器是特练手的程序之一。。 --------------------编程问答-------------------- 给两个积分吧。 --------------------编程问答-------------------- 不错,挺好的,加油!贵在坚持 --------------------编程问答-------------------- 在四樓~ --------------------编程问答-------------------- using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
namespace Calculator
{
public partial class fm_calculator : Form
{
public fm_calculator()
{
InitializeComponent();
}
public static string operation =null;
public static double data_1 = 0;
public static double data_2 = 0;
private void bt_1_Click(object sender, EventArgs e)
{
if (operation == "equal")
{
this.tb_display.Text = null;
operation = null;
this.tb_display.Text = this.tb_display.Text + "1";
}
else
{
this.tb_display.Text = this.tb_display.Text + "1";
}
}
private void bt_2_Click(object sender, EventArgs e)
{
if (operation == "equal")
{
this.tb_display.Text = null;
operation = null;
this.tb_display.Text = this.tb_display.Text + "2";
}
else
{
this.tb_display.Text = this.tb_display.Text + "2";
}
}
private void bt_3_Click(object sender, EventArgs e)
{
if (operation == "equal")
{
this.tb_display.Text = null;
operation = null;
this.tb_display.Text = this.tb_display.Text + "3";
}
else
{
this.tb_display.Text = this.tb_display.Text + "3";
}
}
private void bt_4_Click(object sender, EventArgs e)
{
if (operation == "equal")
{
this.tb_display.Text = null;
operation = null;
this.tb_display.Text = this.tb_display.Text + "4";
}
else
{
this.tb_display.Text = this.tb_display.Text + "4";
}
}
private void bt_5_Click(object sender, EventArgs e)
{
if (operation == "equal")
{
this.tb_display.Text = null;
operation = null;
this.tb_display.Text = this.tb_display.Text + "5";
}
else
{
this.tb_display.Text = this.tb_display.Text + "5";
}
}
private void bt_6_Click(object sender, EventArgs e)
{
if (operation == "equal")
{
this.tb_display.Text = null;
operation = null;
this.tb_display.Text = this.tb_display.Text + "6";
}
else
{
this.tb_display.Text = this.tb_display.Text + "6";
}
}
private void bt_7_Click(object sender, EventArgs e)
{
if (operation == "equal")
{
this.tb_display.Text = null;
operation = null;
this.tb_display.Text = this.tb_display.Text + "7";
}
else
{
this.tb_display.Text = this.tb_display.Text + "7";
}
}
private void bt_8_Click(object sender, EventArgs e)
{
if (operation == "equal")
{
this.tb_display.Text = null;
operation = null;
this.tb_display.Text = this.tb_display.Text + "8";
}
else
{
this.tb_display.Text = this.tb_display.Text + "8";
}
}
private void bt_9_Click(object sender, EventArgs e)
{
if (operation == "equal")
{
this.tb_display.Text = null;
operation = null;
this.tb_display.Text = this.tb_display.Text + "9";
}
else
{
this.tb_display.Text = this.tb_display.Text + "9";
}
}
private void bt_0_Click(object sender, EventArgs e)
{
if (operation == "equal")
{
this.tb_display.Text = null;
operation = null;
this.tb_display.Text = this.tb_display.Text + "0";
}
else
{
this.tb_display.Text = this.tb_display.Text + "0";
}
}
private void bt_dot_Click(object sender, EventArgs e)
{
if (operation == "equal")
{
this.tb_display.Text = null;
operation = null;
if (!this.tb_display.Text.Contains("."))
{
this.tb_display.Text = this.tb_display.Text + ".";
}
}
else
{
if (!this.tb_display.Text.Contains("."))
{
this.tb_display.Text = this.tb_display.Text + ".";
}
}
}
private void bt_plus_Click(object sender, EventArgs e)
{
try
{
data_1 = Convert.ToDouble(this.tb_display.Text);
operation = "plus";
this.tb_display.Clear();
}
catch(Exception ex)
{
MessageBox.Show("请输入数据", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void bt_cut_Click(object sender, EventArgs e)
{
try
{
data_1 = Convert.ToDouble(this.tb_display.Text);
operation = "cut";
this.tb_display.Clear();
}
catch (Exception ex)
{
MessageBox.Show("请输入数据", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void bt_multiply_Click(object sender, EventArgs e)
{
try
{
data_1 = Convert.ToDouble(this.tb_display.Text);
operation = "multiply";
this.tb_display.Clear();
}
catch (Exception ex)
{
MessageBox.Show("请输入数据", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void bt_divide_Click(object sender, EventArgs e)
{
try
{
data_1 = Convert.ToDouble(this.tb_display.Text);
operation = "divide";
this.tb_display.Clear();
}
catch (Exception ex)
{
MessageBox.Show("请输入数据", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void bt_equal_Click(object sender, EventArgs e)
{
try
{
data_2 = Convert.ToDouble(this.tb_display.Text);
double res = 0;
if (data_2 == 0 && operation == "divide")
{
this.tb_display.Text = "被除數不能為0";
}
else
{
switch (operation)
{
case "plus":
res = data_1 + data_2;
this.tb_display.Text = Convert.ToString(res);
break;
case "cut":
res = data_1 - data_2;
this.tb_display.Text = Convert.ToString(res);
break;
case "multiply":
res = data_1 * data_2;
this.tb_display.Text = Convert.ToString(res);
break;
case "divide":
res = data_1 / data_2;
this.tb_display.Text = Convert.ToString(res);
break;
}
operation = "equal";
}
}
catch (Exception ex)
{
MessageBox.Show("请输入数据", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void bt_ce_Click(object sender, EventArgs e)
{
this.tb_display.Clear();
operation = null;
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Close();
Application.Exit();
}
private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
{
MessageBox.Show("软件名称:计算器\n开发环境:Microsoft Visual Studio 2010\n作者:吴建飞", "关于",MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private void moreToolStripMenuItem_Click(object sender, EventArgs e)
{
Process.Start("http://hi.baidu.com/wujianfei0428");
}
}
}
--------------------编程问答-------------------- 1.简化了代码
2.修正2个bug
3.重新在vss 2010中编译(PS:买了新电脑,win 7直接装vss 2010,花了整整半个小时,微软敢不敢把它做得再大一点~) --------------------编程问答-------------------- 大哥或者大姐 其实你做的这个比我做的那个bug要少点 嘿嘿 大家一起加油啊
补充:.NET技术 , C#