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 WindowsFormsApplication1
{
public partial class Form1 : Form
{
int cal, temp, logic;
Boolean a = false;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
if (a == false)
{
textBox1.Text += 1;
}
else
{
textBox1.Text = "1";
a = false;
}
}
private void button2_Click(object sender, EventArgs e)
{
if (a == false)
{
textBox1.Text += 2;
}
else
{
textBox1.Text = "2";
a = false;
}
}
private void button3_Click(object sender, EventArgs e)
{
if (a == false)
{
textBox1.Text += 3;
}
else
{
textBox1.Text = "3";
a = false;
}
}
private void button4_Click(object sender, EventArgs e)
{
if (a == false)
{
textBox1.Text += 4;
}
else
{
textBox1.Text = "4";
a = false;
}
}
private void button5_Click(object sender, EventArgs e)
{
if (a == false)
{
textBox1.Text += 5;
}
else
{
textBox1.Text = "5";
a = false;
}
}
private void button6_Click(object sender, EventArgs e)
{
if (a == false)
{
textBox1.Text += 6;
}
else
{
textBox1.Text = "6";
a = false;
}
}
private void button7_Click(object sender, EventArgs e)
{
if (a == false)
{
textBox1.Text += 7;
}
else
{
textBox1.Text = "7";
a = false;
}
}
private void button8_Click(object sender, EventArgs e)
{
if (a == false)
{
textBox1.Text += 8;
}
else
{
textBox1.Text = "8";
a = false;
}
}
private void button9_Click(object sender, EventArgs e)
{
if (a == false)
{
textBox1.Text += 9;
}
else
{
textBox1.Text = "9";
a = false;
}
}
private void button10_Click(object sender, EventArgs e)
{
if (a == false)
{
textBox1.Text += 0;
}
else
{
textBox1.Text = "0";
a = false;
}
}
private void button11_Click(object sender, EventArgs e)
{
temp = int.Parse(textBox1.Text);
logic = 1;
a = true;
}
private void button12_Click(object sender, EventArgs e)
{
temp = int.Parse(textBox1.Text);
logic = 2;
a = true;
}
private void button13_Click(object sender, EventArgs e)
{
temp = int.Parse(textBox1.Text);
logic = 3;
a = true;
}
private void button14_Click(object sender, EventArgs e)
{
temp = int.Parse(textBox1.Text);
logic = 4;
a = true;
}
private void button15_Click(object sender, EventArgs e)
{
switch (logic)
{
case 1:
cal = temp + int.Parse(textBox1.Text);
textBox1.Text = cal.ToString();
break;
case 2:
cal = temp - int.Parse(textBox1.Text);
textBox1.Text = cal.ToString();
break;
case 3:
cal = temp * int.Parse(textBox1.Text);
textBox1.Text = cal.ToString();
break;
case 4:
if (int.Parse(textBox1.Text) != 0)
{
cal = temp / int.Parse(textBox1.Text);
textBox1.Text = cal.ToString();
}
else
{
MessageBox.Show("除數不得為零!");
}
break;
}
a = true;
}
}
}
沒有留言:
張貼留言