C#实现Winform版计算器
作者:lijiao 发布时间:2023-01-25 06:59:37
标签:C#,Winform,计算器
本文实例为大家分享Winform版计算器的具体实现方法,供大家参考,具体内容如下
前台页面设计
后台代码实现
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace 计算器
{
public partial class Form1 : Form
{
double c, d;
string m;
public Form1()
{
InitializeComponent();
}
private void button2_Click(object sender, EventArgs e)
{
}
private void button8_Click(object sender, EventArgs e)
{
textBox1.Text += button8.Text;
}
private void button1_Click(object sender, EventArgs e)
{
textBox1.Text += button1.Text;
}
private void button2_Click_1(object sender, EventArgs e)
{
textBox1.Text += button2.Text;
}
private void button3_Click(object sender, EventArgs e)
{
textBox1.Text += button3.Text;
}
private void button4_Click(object sender, EventArgs e)
{
textBox1.Text += button4.Text;
}
private void button5_Click(object sender, EventArgs e)
{
textBox1.Text += button5.Text;
}
private void button6_Click(object sender, EventArgs e)
{
textBox1.Text += button6.Text;
}
private void button7_Click(object sender, EventArgs e)
{
textBox1.Text += button7.Text;
}
private void button9_Click(object sender, EventArgs e)
{
textBox1.Text += button9.Text;
}
private void button10_Click(object sender, EventArgs e)
{
textBox1.Text += button10.Text;
}
private void button15_Click(object sender, EventArgs e)
{
d= Convert.ToDouble(textBox1.Text);
switch (m)
{
case("+"):
textBox1.Text = Convert.ToString(c+d);
break;
case ("-"):
textBox1.Text = Convert.ToString(c-d);
break;
case ("*"):
textBox1.Text = Convert.ToString(c * d);
break;
case ("/"):
textBox1.Text = Convert.ToString(c/d);
break;
}
}
private void button11_Click(object sender, EventArgs e)
{
c = Convert.ToDouble(textBox1.Text);
textBox1.Text = "";
m = button11.Text;
}
private void button12_Click(object sender, EventArgs e)
{
c = Convert.ToDouble(textBox1.Text);
textBox1.Text = "";
m = button12.Text;
}
private void button13_Click(object sender, EventArgs e)
{
c= Convert.ToDouble(textBox1.Text);
textBox1.Text = "";
m = button13.Text;
}
private void button14_Click(object sender, EventArgs e)
{
c = Convert.ToDouble(textBox1.Text);
textBox1.Text = "";
m = button14.Text;
}
private void button16_Click(object sender, EventArgs e)
{
textBox1.Text = "";
}
}
}
0
投稿
猜你喜欢
- 关于Unity的换装,网上有几篇文章,我之前也简单的描述过实现。不过那个时候只是粗略的试验了下。今天好好梳理了下代码。先上代码(自己的游戏项
- 前言我昨天做了个梦,我梦见我在一条路走,走的时候经过一个房间,里面关着一条边牧和鸡和猪,后来我醒了,我知道那只边牧就是小叶子(哈仔十一的边牧
- 绑定(Binding)元素介绍首先,盗用张图。这图形象的说明了Binding的机理。此处主要介绍的绑定类是System.Windows.Da
- 每次写批量的时候,都要在网上搜索一下,虽然都做过多次了,但具体的自己还是记不住(汗颜),所以索性今天就记录下来。前期说明:foreach的主
- 哈希表的分离链接法原理Hash Table可以看作是一种特殊的数组。他的原理基本上跟数组相同,给他一个数据,经过自己设置的哈希函数变换得到一
- 本文实例讲述了在WPF中动态加载XAML中的控件的方法。分享给大家供大家参考,具体如下:using System;using System.
- 步骤,如图所示:1.添加异步任务业务类package top.ytheng.demo.task;import java.util.concu
- 启动Springboot项目时候报错java: 无法访问org.springframework.boot.SpringApplication
- 本文实例讲述了Java Swing实现让窗体居中显示的方法。分享给大家供大家参考,具体如下:Swing组件是AWT组建的增强组件,是功能强大
- 一般都在windows下开发的,现在部署到linux下:1,将项目达成war包(用eclipse,项目右键-->Export-->
- 安卓虽然已经成为了移动设备第一操作系统,且影响力也延伸到了汽车和tv端,不过对于谷歌来说,需要依靠Java来做安卓开发一直是一个心病,因为O
- 在Java 5以前,是用synchronized关键字来实现锁的功能。synchronized关键字可以作为方法的修饰符(同步方法),也可作
- JSON.toJSONString格式化成json字符串时保留null属性使用阿里的com.alibaba.fastjson.JSON格式化
- 前言Spring5带来了新的响应式web开发框架WebFlux,同时,也引入了新的HttpClient框架WebClient。WebClie
- 本文实例为大家分享了java实现Dijkstra算法的具体代码,供大家参考,具体内容如下1 问题描述何为Dijkstra算法?Dijkstr
- 一、简介二、代码/activityLifeCycle_3Screen/AndroidManifest.xml<manifest xml
- 1、简介对于数据访问层,无论是SQL(关系型数据库) 还是NOSQL(非关系型数据库),SpringBoot 底层都是采用 SpringDa
- spring Boot 允许通过外部配置让你在不同的环境使用同一应用程序的代码,简单说就是可以通过配置文件来注入属性或者修改默认的配置。Sp
- 获取自定义菜单查询返回的结果有乱码解决方法:string Posturl = "https://api.weixin.qq.com
- 一、添加数据1、在主表中添加从表数据在景点的住宿集合(Lodgings)中增加一个度假区(Resort)var dest = (from d