Saturday, February 11, 2017

Simple Windows Form Application for Addition in Visual Studio

Code:

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

        private void textBox2_TextChanged(object sender, EventArgs e)
        {

        }

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

        private void button1_Click(object sender, EventArgs e)
        {
            float a = float.Parse(richTextBox1.Text);
            float b = float.Parse(richTextBox2.Text);
            float add = a + b;
            richTextBox3.Text = add.ToString();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            MessageBox.Show("Click OK to exit from window");
            this.Close();
           
        }

        private void textBox3_TextChanged(object sender, EventArgs e)
        {

        }

        private void richTextBox1_TextChanged(object sender, EventArgs e)
        {

        }
    }
}

Output:

Windows form application to show addition of two numbers:


 
As we click on exit button, one message box appears as:

 




No comments:

Post a Comment