C# 计算器设计 代码,及过程图解

来源:百度知道 编辑:UC知道 时间:2024/07/07 14:44:22
C#设计计算机 过程 全解............

你看行不,你慢慢的看就没有什么问题的啊!QQ联系877737008
C#编写的windows计算器
初学C#时写的比较基础的windows Form 程序,该计算器实现了基础的数学运算,如加,减,乘,除等任务.主要是通过该程序学习vs.net的编程环境,以及windows Form程序. 如图
步骤如下:
1.新建一个windows应用程序
2.在窗体上添加21个按钮作为计算器的按键,并设计这些控件的Name和Text属性,再在表单中添加一个文本框控件,将其Text属性设为空。
3.设置清除按钮btn_clear,并添加清除所有全局变量及文本框内容的代码,在form1.cs中定义一个方法append_num(i),用于处理编辑框中输入的数字;为数字为0的按钮添加click事件btuuon0_click,在该事件的处理代码中处理所有数字的输入,然后其他的数字按钮共享该代码,所有这些按钮通过sender对象来确定当前用户选择的安钮;为”+“号按钮添加click事件btn_plus_click事件,并使log,exp,sqrt等按钮的ckick事件共享该事件的代码。
下面是Form1.cs的代码:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace jisuanqi
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
priv