using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace 小算盤
{
public enum op
{
NoAction,
ADD,
SUB,
MUL,
DIV
}
public partial class Form1 : Form
{
public op currentOp = op.NoAction;
public double currentValue = 0,lastValue = 0;
public bool needClear = false;
public StringBuilder ac = new StringBuilder();
public Form1()
{
InitializeComponent();
}
private void SetValue(string s)
{
if (needClear || textBox1.Text == "0")
{
ac.Length = 0;
ac.Append(s);
textBox1.Text = ac.ToString();
needClear = false;
}
else
{
ac.Append(s);
textBox1.Text = ac.ToString();
}
}
private void exc()
{
currentValue = double.Parse(textBox1.Text);
switch (currentOp)
{
case op.ADD:
currentValue = lastValue + currentValue;
break;
case op.SUB:
if (lastValue != 0)
{
currentValue = lastValue - currentValue;
}
break;
case op.MUL:
if (lastValue != 0)
{
currentValue = lastValue * currentValue;
}
break;
case op.DIV:
if (lastValue != 0 && currentValue != 0)
{
currentValue = (lastVal ..
訪客只能看到部份內容,免費 加入會員 或由臉書 Google 可以看到全部內容