#EX5 โปรแกรมบวกเลข โดยใช้ NumericUpDown

เป็นโปรแกรมบวกเลข 2 ตัวแปร

NumericUpDown

Code

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 NumericUpDowns
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }





        private void Submit_Click(object sender, EventArgs e)
        {
            string num1 = null;
            num1 = numUD1.Value.ToString();
            string num2 = null;
            num2 = numUD2.Value.ToString();
            int num3 = int.Parse(num1);
            int num4 = int.Parse(num2);
            int result = 0;
            result = num3 + num4;
            //MessageBox.Show(result.ToString(), "ผล");
            textBox1.Text = result.ToString();
            
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            
            
        }

        private void numUD1_ValueChanged(object sender, EventArgs e)
        {

        }

        private void numUD2_ValueChanged(object sender, EventArgs e)
        {

        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void label3_Click(object sender, EventArgs e)
        {

        }

        private void groupBox1_Enter(object sender, EventArgs e)
        {

        }
    }
}

2021-09-23_17-30-40

สามารถดาวน์โหลดไฟล์ไปลองเล่นดูได้ครับ NumericUpDowns.rar (49.4 KB)