CH02_3

计算两个数的和(窗体应用程序)直接在窗体中显示

laber:a,b,c     textBox:输入值的地方   button:求和,求差
求和:
 private void button1_Click(object sender, EventArgs e)
        {
            float a, b, s;
            a = float.Parse(this.textBox1.Text);
            b = float.Parse(this.textBox2.Text);
            s = a + b;
            this.textBox3.Text = s.ToString();
        }


  求差:
        private void button2_Click(object sender, EventArgs e)
        {
            float a, b, s;
            a = float.Parse(this.textBox1.Text);
            b = float.Parse(this.textBox2.Text);
            s = a - b;
            this.textBox3.Text = s.ToString();  //在窗体中显示
        }

你可能感兴趣的:(CH02_3)