资源简介
C# 计算器 仿windows计算器,支持小数点计算,不支持键盘输入

代码片段和文件信息
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace 计算器
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
double sum = 0;//上一步运算结果
string op = ““ ops = ““;//选择的运算符
string old_op = ““;//换运算符
int op_times=1;//单次计算的运算符按下次数
int times = 0;//计算次数
bool restart = false;//按下等于号
//输入数
private void button_number(object sender EventArgs e)
{
Button button = (Button)sender;
//输入
if (ops == ““ )
{
if (label.Text == “0“ || restart)
{
if(button.Text==“.“)
{
label.Text = “0“+button.Text;
}
else
{
label.Text = button.Text;
}
restart = false;
}
else
{
label.Text = label.Text + button.Text;
}
}
else
{
op = ops;
ops = ““;
if (button.Text == “.“)
{
label.Text = “0“ + button.Text;
}
else
{
label.Text = button.Text;
}
op_times = 1;
times++;
}
//小数点无法点击
if (label.Text.IndexOf(“.“) == -1)
button19.Enabled = true;
else
button19.Enabled = false;
}
//操作符号
private void button_op(object sender EventArgs e)
{
Button button = (Button)sender;
//运算符
if (button.Text != “=“)
{
ops = button.Text;
if(times<1)
{
sum = Convert.ToDouble(label.Text);
}
//判断按下符号位时只出现一次
if(op_times==1)
{
labels.Text = labels.Text + label.Text + ops;
old_op = ops;
op_times = 0;
}
else
{
labels.Text = labels.Text.Replace(old_op ops);
old_op = ops;
}
//运算符计算
if (times >= 1)
{
operation(sum Convert.ToDouble(label.Text) op);
label.Text = Convert.ToString(sum);
}
}
//等于号
else if (button.Text == “=“)
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-10-29 16:40 计算器\
目录 0 2018-10-29 16:40 计算器\.vs\
目录 0 2018-10-29 16:40 计算器\.vs\计算器\
目录 0 2018-10-29 16:41 计算器\.vs\计算器\v15\
文件 56832 2018-12-12 22:35 计算器\.vs\计算器\v15\.suo
目录 0 2018-10-29 16:41 计算器\.vs\计算器\v15\Server\
目录 0 2018-10-29 16:41 计算器\.vs\计算器\v15\Server\sqlite3\
文件 0 2018-10-29 16:41 计算器\.vs\计算器\v15\Server\sqlite3\db.lock
文件 581632 2018-10-30 16:31 计算器\.vs\计算器\v15\Server\sqlite3\storage.ide
文件 32768 2018-12-12 20:10 计算器\.vs\计算器\v15\Server\sqlite3\storage.ide-shm
文件 4128272 2018-11-04 21:10 计算器\.vs\计算器\v15\Server\sqlite3\storage.ide-wal
目录 0 2018-12-12 20:08 计算器\计算器\
目录 0 2018-11-02 20:40 计算器\计算器\.git\
文件 23 2018-11-02 20:40 计算器\计算器\.git\HEAD
文件 190 2018-11-02 20:40 计算器\计算器\.git\config
文件 73 2018-11-02 20:40 计算器\计算器\.git\desc
目录 0 2018-11-02 20:40 计算器\计算器\.git\hooks\
文件 478 2018-11-02 20:40 计算器\计算器\.git\hooks\applypatch-msg.sample
文件 896 2018-11-02 20:40 计算器\计算器\.git\hooks\commit-msg.sample
文件 3327 2018-11-02 20:40 计算器\计算器\.git\hooks\fsmonitor-watchman.sample
文件 189 2018-11-02 20:40 计算器\计算器\.git\hooks\post-update.sample
文件 424 2018-11-02 20:40 计算器\计算器\.git\hooks\pre-applypatch.sample
文件 1638 2018-11-02 20:40 计算器\计算器\.git\hooks\pre-commit.sample
文件 1348 2018-11-02 20:40 计算器\计算器\.git\hooks\pre-push.sample
文件 4898 2018-11-02 20:40 计算器\计算器\.git\hooks\pre-reba
文件 544 2018-11-02 20:40 计算器\计算器\.git\hooks\pre-receive.sample
文件 1492 2018-11-02 20:40 计算器\计算器\.git\hooks\prepare-commit-msg.sample
文件 3610 2018-11-02 20:40 计算器\计算器\.git\hooks\update.sample
目录 0 2018-11-02 20:40 计算器\计算器\.git\info\
文件 240 2018-11-02 20:40 计算器\计算器\.git\info\exclude
目录 0 2018-11-02 20:40 计算器\计算器\.git\ob
............此处省略58个文件信息
- 上一篇:c#上位机数据采集源代码
- 下一篇:基于凸包多边形的填挖方量计算程序
相关资源
- C# OCR数字识别实例,采用TessnetOcr,对
- 考试管理系统 - C#源码
- asp.net C#购物车源代码
- C#实时网络流量监听源码
- C#百度地图源码
- Visual C#.2010从入门到精通配套源程序
- C# 软件版本更新
- C#屏幕软键盘源码,可以自己定制界面
- 智慧城市 智能家居 C# 源代码
- c#获取mobile手机的IMEI和IMSI
- C#实现简单QQ聊天程序
- 操作系统 模拟的 欢迎下载 C#版
- C#写的计算机性能监控程序
- 用C#实现邮件发送,有点类似于outlo
- MVC model层代码生成器 C#
- c#小型图书销售系统
- C# Socket Server Client 通讯应用 完整的服
- c# winform 自动登录 百度账户 源代码
- C#编写的16进制计算器
- C#TCP通信协议
- C# 数据表(Dataset)操作 合并 查询一
- C#语音识别系统speechsdk51,SpeechSDK51L
- 数据库备份还原工具1.0 C# 源码
-
[免费]xm
lDocument 节点遍历C# - EQ2008LEDc#开发实例
- DirectX.Capturec# winform 操作摄像头录像附
- c# 实现的最大最小距离方法对鸢尾花
- C#版保龄球记分代码
- C#自定义控件
- 基于c#的实验室设备管理系统621530
评论
共有 条评论