close

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 WindowsFormsApplication4
{
public partial class Form1 : Form
{
string n1 ,n2 ,m1 ,m2 ,ans;
float a;
public Form1()
{
InitializeComponent();
}
private void label1_Click(object sender, EventArgs e)
{
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
n1 = textBox1.Text;
n2 = textBox2.Text;
float f1 = float.Parse(n1);
float f2 = float.Parse(n2);
a = f1 + f2;
ans = a.ToString();
label2.Text = ans;
label3.Text = "+";
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
n1 = textBox1.Text;
n2 = textBox2.Text;
float f1 = float.Parse(n1);
float f2 = float.Parse(n2);
a = f1 - f2;
ans = a.ToString();
label2.Text = ans;
label3.Text = "-";
}
private void button3_Click(object sender, EventArgs e)
{
n1 = textBox1.Text;
n2 = textBox2.Text;
float f1 = float.Parse(n1);
float f2 = float.Parse(n2);
a = f1 * f2;
ans = a.ToString();
label2.Text = ans;
label3.Text = "*";
}
private void button4_Click(object sender, EventArgs e)
{
n1 = textBox1.Text;
n2 = textBox2.Text;
float f1 = float.Parse(n1);
float f2 = float.Parse(n2);
a = f1 / f2;
ans = a.ToString();
label2.Text = ans;
if (f2 == 0)
label2.Text="不存在";
label3.Text = "/";
}
}
}
全站熱搜