คำสั่ง if คำนวน vs2010 
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication4
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        void sub()
        {
            int a = 0; int b = 0; int c = 0;
            a = Int32.Parse(textBox1.Text);
            b = Int32.Parse(textBox2.Text);
            if (a > b)
                c = a - b;
            else if (b > a)
                c = b - a;
            label3.Text = c.ToString();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            sub();
        }
    }
}
 
ไม่มีความคิดเห็น:
แสดงความคิดเห็น