程式設計工藝大師
應數物件導向設計C#
D0250429 許瑞峰
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
string b1, b2;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
float c1;
b1 = textBox1.Text;
b2 = textBox2.Text;
float a1 = float.Parse(b1);
float a2 = float.Parse(b2);
c1 = a1 + a2;
label2.Text = c1.ToString();
}
private void button2_Click(object sender, EventArgs e)
{
float c1;
b1 = textBox1.Text;
b2 = textBox2.Text;
float a1 = float.Parse(b1);
float a2 = float.Parse(b2);
c1 = a1 - a2;
label2.Text = c1.ToString();
}
private void button3_Click(object sender, EventArgs e)
{
float c1;
b1 = textBox1.Text;
b2 = textBox2.Text;
float a1 = float.Parse(b1);
float a2 = float.Parse(b2);
c1 = a1 * a2;
label2.Text = c1.ToString();
}
private void button4_Click(object sender, EventArgs e)
{
float c1;
b1 = textBox1.Text;
b2 = textBox2.Text;
float a1 = float.Parse(b1);
float a2 = float.Parse(b2);
c1 = a1 / a2;
label2.Text = c1.ToString();
if (a2 == 0)
{
label2.Text = "除數不可為零";
}
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void label1_Click(object sender, EventArgs e)
{
}
}
}