{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string b1, b2;
b1 = textBox1.Text;
b2 = textBox2.Text;
float numval1 = float.Parse(b1);
float numval2 = float.Parse(b2);
float numsum = numval1 + numval2;
label2.Text = numsum.ToString();
}
private void button2_Click(object sender, EventArgs e)
{
string b1, b2;
b1 = textBox1.Text;
b2 = textBox2.Text;
float numval1 = float.Parse(b1);
float numval2 = float.Parse(b2);
float numsum = numval1 - numval2;
label2.Text = numsum.ToString();
}
private void button3_Click(object sender, EventArgs e)
{
string b1, b2;
b1 = textBox1.Text;
b2 = textBox2.Text;
float numval1 = float.Parse(b1);
float numval2 = float.Parse(b2);
float numsum = numval1 * numval2;
label2.Text = numsum.ToString();
}
private void button4_Click(object sender, EventArgs e)
{
float a = float.Parse(textBox1.Text), b = float.Parse(textBox2.Text);
string b1, b2;
b1 = textBox1.Text;
b2 = textBox2.Text;
float numval1 = float.Parse(b1);
float numval2 = float.Parse(b2);
float numsum = numval1 / numval2;
label2.Text = numsum.ToString();
if (b == 0)
{
label2.Text = "分母為零";
}
else
{
label2.Text = (a / b).ToString();
}
}
}
}
沒有留言:
張貼留言