- 0
- 0
- 约7.68千字
- 约 7页
- 2019-03-30 发布于湖北
- 举报
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 Study
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private int opMain = 0; // 运算类型,其中1(加法) 2(减法) 3(乘法) 4(除法)
private double mainNum1 = 0; // 存储第一个数
private double mainNum2 = 0; // 存储第二个数
private bool isSecond = false; // 用来判断输入的是第一个还是第二个数
private bool isDone = false; // 用来判断是否按了等于按钮
private bool isDecimal = false; // 用来判断是否有小数
private bool isNokeydown = false;// 用来判断是否没输入第二个数而按了=号键
private bool isKeyupclear = true;//用来判断是否按了clear键,程序开始前默认按了;
public void setText(string textest) //设置文本框的值
{
if (textest.Equals(clear))
{
textBox1.Text = 0.;
isSecond = false;
isDone = false;
isDecimal = false;
isKeyupclear = true;
}
else
{
if (isSecond)
{
textBox1.Text = textest;
isSecond = false;
isDecimal = false;
}
else
{
if (isDone)
{
textBox1.Text = textest;
isDone = false;
}
else
{
if (isKeyupclear) //对是否按下clear键的判断
{
textBox1.Text = textest;
isKeyupclear = false;
}
else
textBox1.Text += textest;
}
}
}
btnEqual.Select(); //设置=号的焦点
原创力文档

文档评论(0)