string a,b;
public Form1()
{
InitializeComponent();
}
private void textBox1_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 textBox2_TextChanged(object sender, EventArgs e)
{
}
private void label3_Click(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
label3.Text = "+";
a = textBox1.Text;
b = textBox2.Text;
float c = float.Parse(a);
float d = float.Parse(b);
string e1 = (c+d).ToString();
label2.Text = e1.ToString();
}
private void button2_Click(object sender, EventArgs e)
{
label3.Text = "-";
a = textBox1.Text;
b = textBox2.Text;
float c = float.Parse(a);
float d = float.Parse(b);
string e1 = (c - d).ToString();
label2.Text = e1.ToString();
}
private void button3_Click(object sender, EventArgs e)
{
label3.Text = "*";
a = textBox1.Text;
b = textBox2.Text;
float c = float.Parse(a);
float d = float.Parse(b);
string e1 = (c * d).ToString();
label2.Text = e1.ToString();
}
private void button4_Click(object sender, EventArgs e)
{
label3.Text = "/";
a = textBox1.Text;
b = textBox2.Text;
float c = float.Parse(a);
float d = float.Parse(b);
if (d == 0)
label2.Text = "Error";
else
{
string e1 = (c / d).ToString();
label2.Text = e1.ToString();
}
}
}
}
沒有留言:
張貼留言