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;
public Form1()
{
InitializeComponent();
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
}
private void label1_Click(object sender, EventArgs e)
{
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void label2_Click(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
float a = float.Parse(textBox1.Text); // 將textBox的字串轉換為單精數
float b = float.Parse(textBox2.Text); // 同上
label2.Text = (a + b).ToString(); // 將兩個計算的結果轉成字串
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
float a = float.Parse(textBox1.Text); // 將textBox的字串轉換為單精數
float b = float.Parse(textBox2.Text); // 同上
label2.Text = (a - b).ToString(); // 將兩個計算的結果轉成字串
}
private void button3_Click(object sender, EventArgs e)
{
float a = float.Parse(textBox1.Text); // 將textBox的字串轉換為單精數
float b = float.Parse(textBox2.Text); // 同上
label2.Text = (a * b).ToString(); // 將兩個計算的結果轉成字串
}
private void button4_Click(object sender, EventArgs e)
{
float a = float.Parse(textBox1.Text); // 將textBox的字串轉換為單精數
float b = float.Parse(textBox2.Text); // 同上
label2.Text = (a / b).ToString(); // 將兩個計算的結果轉成字串
if(b==0)
{
label2.Text ="除數不可為0,請重新輸入";
}
}
private void button5_Click(object sender, EventArgs e)
{
}
}
}