close
C%236.jpg 

--------------------------------------------------------------------------------

namespace WindowsFormsApplication3
{
    public partial class Form1 : Form
    {
        String a1, a2,b;
        float numVal, num1, num2;
        public Form1()
        {
            InitializeComponent();
        }
        private void textBox1_TextChanged(object sender, EventArgs e)
        {
        }
        private void textBox2_TextChanged(object sender, EventArgs e)
        {
        }
        private void button1_Click(object sender, EventArgs e)
        {
            label1.Text = button1.Text;
            a1 = textBox1.Text;
            float num1 = float.Parse(a1);
            a2 = textBox2.Text;
            float num2 = float.Parse(a2);
            float numVal = num1 + num2;
            label3.Text=numVal.ToString();
        }

        private void button2_Click(object sender, EventArgs e)

        {
            label1.Text = button2.Text;
            a1 = textBox1.Text;
            float num1 = float.Parse(a1);
            a2 = textBox2.Text;
            float num2 = float.Parse(a2);
            float numVal = num1 - num2;
            label3.Text = numVal.ToString();
        }
        private void button3_Click(object sender, EventArgs e)
        {
            label1.Text = button3.Text;
            a1 = textBox1.Text;
            float num1 = float.Parse(a1);
            a2 = textBox2.Text;
            float num2 = float.Parse(a2);
            float numVal = num1 * num2;
            label3.Text = numVal.ToString();
        }
        private void button4_Click(object sender, EventArgs e)
        {
            label1.Text = button4.Text;
            a1 = textBox1.Text;
            float num1 = float.Parse(a1);
            a2 = textBox2.Text;
            float num2 = float.Parse(a2);
            if (num2 == 0)
            {
                String b = "Error";
                label3.Text = b;
            }
            else
            {
                float numVal = num1 / num2;
                label3.Text = numVal.ToString();
            }
        }
        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void label2_Click(object sender, EventArgs e)
        {
        }
        private void label3_Click(object sender, EventArgs e)
        {
        }
    }
}
arrow
arrow
    全站熱搜

    lasmilou 發表在 痞客邦 留言(0) 人氣()