using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
float a , b,c;
public Form1()
{
InitializeComponent();
}
private void label1_Click(object sender, EventArgs e)
{
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void label2_Click(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
a = float.Parse(textBox1.Text);
c = 1;
textBox1.Text = "";
}
private void label3_Click(object sender, EventArgs e)
{
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
}
private void button6_Click(object sender, EventArgs e)
{
a = float.Parse(textBox1.Text);
c = 2;
textBox1.Text = "";
}
private void button5_Click(object sender, EventArgs e)
{
a = float.Parse(textBox1.Text);
c = 3;
textBox1.Text = "";
}
private void button3_Click(object sender, EventArgs e)
{
a = float.Parse(textBox1.Text);
c = 4;
textBox1.Text = "";
}
private void button4_Click(object sender, EventArgs e)
{
a = float.Parse(textBox1.Text);
label3.Text = (1/a).ToString();
textBox1.Text = label3.Text;
c = 5;
}
private void button2_Click(object sender, EventArgs e)
{
a = float.Parse(textBox1.Text);
label3.Text = (a*a).ToString();
textBox1.Text = label3.Text;
c = 6;
}
private void button7_Click(object sender, EventArgs e)
{
b = float.Parse(textBox1.Text);
if (c == 1)
{
label3.Text = (a + b).ToString();
}
else if (c == 2)
{
label3.Text = (a - b).ToString();
}
else if (c == 3)
{
label3.Text = (a * b).ToString();
}
else if (c == 4)
{
if (b == 0)
{
label3.Text = "分母不能為零";
}
else
{
label3.Text = (a / b).ToString();
}
}
else
{
textBox1.Text = label3.Text;
}
textBox1.Text = label3.Text;
}
private void button8_Click(object sender, EventArgs e)
{
textBox1.Text="";
label3.Text = "";
}
}
}
沒有留言:
張貼留言