public partial class Form1 : Form
{
String aa;
String m;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
button1 = sender as Button;
textBox1.Text += button1.Text;
}
private void label1_Click(object sender, EventArgs e)
{
}
private void button11_Click(object sender, EventArgs e)
{
textBox1.Text = "";
}
private void button10_Click(object sender, EventArgs e)
{
button10 = sender as Button;
textBox1.Text += button10.Text;
}
private void button2_Click(object sender, EventArgs e)
{
button2 = sender as Button;
textBox1.Text += button2.Text;
}
private void button3_Click(object sender, EventArgs e)
{
button3 = sender as Button;
textBox1.Text += button3.Text;
}
private void button4_Click(object sender, EventArgs e)
{
button4 = sender as Button;
textBox1.Text += button4.Text;
}
private void button5_Click(object sender, EventArgs e)
{
button5 = sender as Button;
textBox1.Text += button5.Text;
}
private void button6_Click(object sender, EventArgs e)
{
button6 = sender as Button;
textBox1.Text += button6.Text;
}
private void button7_Click(object sender, EventArgs e)
{
button7 = sender as Button;
textBox1.Text += button7.Text;
}
private void button8_Click(object sender, EventArgs e)
{
button8 = sender as Button;
textBox1.Text += button8.Text;
}
private void button9_Click(object sender, EventArgs e)
{
button9 = sender as Button;
textBox1.Text += button9.Text;
}
private void button19_Click(object sender, EventArgs e)
{
if (aa == null)
return;
Double a = Double.Parse(aa);
Double b = float.Parse(textBox1.Text);
Double d = float.Parse(textBox1.Text);
Double c = 0;
switch (m)
{
case "+":
c = a + b;
break;
case "-":
c = a - b;
break;
case "*":
c = a * b;
break;
case "/":
c = a / d;
break;
}
textBox1.Text = c.ToString();
if (d == 0) textBox1.Text = "除數不為零";
}
private void button12_Click(object sender, EventArgs e)
{
button12 = sender as Button;
m = button12.Text;
aa = textBox1.Text;
textBox1.Text = "";
}
private void button13_Click(object sender, EventArgs e)
{
button13 = sender as Button;
m = button13.Text;
aa = textBox1.Text;
textBox1.Text = "";
}
private void button14_Click(object sender, EventArgs e)
{
button14 = sender as Button;
m = button14.Text;
aa = textBox1.Text;
textBox1.Text = "";
}
private void button15_Click(object sender, EventArgs e)
{
button15 = sender as Button;
m = button15.Text;
aa = textBox1.Text;
textBox1.Text = "";
}
private void button17_Click(object sender, EventArgs e)
{
button17 = sender as Button;
m = button17.Text;
aa = textBox1.Text;
textBox1.Text = "";
Double a = Double.Parse(aa);
Double c = 0;
c = Math.Sqrt(a);
textBox1.Text = c.ToString();
}
private void button18_Click(object sender, EventArgs e)
{
button18 = sender as Button;
m = button18.Text;
aa = textBox1.Text;
textBox1.Text = "";
Double a = Double.Parse(aa);
Double c = 0;
c =1/a;
textBox1.Text = c.ToString();
if (a == 0) textBox1.Text = "除數不為零";
}
private void button20_Click(object sender, EventArgs e)
{
button20 = sender as Button;
textBox1.Text += button20.Text;
}
private void button16_Click(object sender, EventArgs e)
{
if (textBox1.Text.Length > 0)
{
textBox1.Text = textBox1.Text.Substring(0, textBox1.Text.Length - 1);
}
}
}
沒有留言:
張貼留言