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 = "";
}
}
}


猜你喜欢
- Struts2的核心在于它复杂的 * ,几乎70%的工作都是由 * 完成的。比如我们之前用于将上传的文件对应于action实例中的三个属性的
- 本文主要对SpringBoot2.x参数校验进行简单总结,其中SpringBoot使用的2.4.5版本。一、引入依赖<dependen
- 有时候我们需要实现这样的场景,类似进入开发者模式,即多次点击后执行操作。首先我们先看一个方法:System提供的一个静态方法arraycop
- 概述工作电脑用了3年多了,100G的C盘也快吃不消了,每次打开看到C盘红了,总要用清理工具清理一下子.不知道怎么最近清理工具清理
- 前言 我们都知道,finally在捕获异常的操作中,总是最
- 沉浸式状态栏是Android4.4即api19以上才支持的特性,分两步实现:1.在布局文件中第一个控件(一般是imageview或者text
- 开发环境win10Android Studio效果用于多级菜单展示,或选择。如 每个省,市,县;如 树木的病虫害;关键代码 @overrid
- 本文实例为大家分享了UnityShader3实现彩光效果展示的具体代码,供大家参考,具体内容如下参考链接: 【OpenGL】Shader实例
- 简介String是我们最常用的一个类,和普通java类一样其对象会存在java堆中。但是String类有其特殊之处,可以通过new方法生成,
- 一、区别和联系异步和多线程有什么区别?其实,异步是目的,而多线程是实现这个目的的方法。异步是说,A发起一个操作后(一般都是比较耗时的操作,如
- 1. Mybatis JdbcType与Oracle、MySql数据类型对应列表MybatisJdbcTypeOracleMySqlJdbc
- 本文实例为大家分享了C#实现截图工具小项目的具体代码,供大家参考,具体内容如下1.起因一直用的截图是qq的截图,所以想要实现一个简单点的截图
- package com.test; import java.io.FileNotFoundException;&nbs
- 自定义View实现一个弹性滑动的效果,供大家参考,具体内容如下实现原理onMeasure()中测量所有子View @Override pro
- 以前的Android(4.1之前的版本)中,SDcard路径通过“/sdcard”或者“/mnt/sdcard”来表示,而在JellyBea
- 最近在维护项目,app遇到安装在高版本的Android时,以往直接授权和new File(path)的形式不再支持,日志也是说Permiss
- 定义队列是 Apache RocketMQ 中消息存储和传输的实际容器,也是 Apache RocketMQ 消息的最小存储单元。 Apac
- 本文实例讲述了Android使用criteria选择合适的地理位置服务实现方法。分享给大家供大家参考,具体如下:/* LocationAct
- SelectMany操作符提供了将多个from子句组合起来的功能,相当于数据库中的多表连接查询,它将每个对象的结果合并成单个序列。示例:st
- yaml中的数组类型取值yaml中简单的风格,十分受大家的欢迎先说下简单的配置如何取值# application-dev.yml testV