How to build a Calculator in Visual Studio and Install it on Your Client System

By
Hi Friends ! Today i am going to build a simple Calculator application using C# in Visual studio 2010 /2012.I will create a setup file(.exe file)of this application in visual studio 2010/2012.But i Will show you "How to create setup file in visual studio 2012 'only .Because I have already explained "How to create setup file in visual studio 20008/2010" in our previous tutorial. Some students want to create setup file in visual studio 2012.So in this post i will create a setup file using visual studio 2012 .In visual studio 2012 Ultimate has some limited functionality to create setup file in best way. all students mostly use Demo version of visual studio that has a limited functionality.Visual studio 2012 is the enhancement (some Updation) of Visual studio 2010.So i would like to say you,use visual studio 20008/2010 for creating a effective setup file and other purpose use visual studio 2012.You can receive both visual studio setup file through Bottom Download link .You can check yourself which is more better.You can install this setup file in your Window xp/Vista/7 /8 easily and use it for your calculation purpose.I hope this application will more helpful to you/Friends and your clients. 
There are some steps to build this setup file in visual studio 2012 which are given below:-

Step 1:- First Open Your visual studio-->File -->New -->project -->Select Windows Forms Application -->OK-->Open Solution Explorer (by press View Button) -->Add a New Web Form.
Step 2:- Now Drag and Drop Button ,TextBox and Label control from Toolbox on the Form as shown below:-
Form
Step 4:- Now Right click on each Button -->Go Properties --> Press Events Icon -->Now Create button event handler [Numeric Button(0,1,2,3,4,5,6,7,8,.) ,Operator button(-,+,*,/) ,CA Button ,Ac Button ,Equal button,Off Button] manually as shown below:-
  
calculator

Note :- You have to put all Numeric button to under Numeric_button_click  event, similarly put other button also.
Step 3:- Now Write the C# Codes in Form.cs File inside each event handlers which i have created manually as given below:-
using System;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace First_calculator
{
    public partial class Form1 : Form
    {
        string op_value = "";
        double txt_value=0;
        bool bool_value = false;
        public Form1()
        {
            InitializeComponent();
        }

        private void Numeric_button_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "0" || bool_value)
                textBox1.Clear();
            bool_value = false;
            Button bu = (Button)sender;
            textBox1.Text = textBox1.Text + bu.Text;
        }

        private void off_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void CE_button_Click(object sender, EventArgs e)
        {
            textBox1.Text = "0";
            label1.Text = null;
        }

        private void AC_button_Click(object sender, EventArgs e)
        {
            textBox1.Clear();
            op_value = "0";
            label1.Text = null;
        }
        private void operator_click(object sender, EventArgs e)
        {
                Button bu = (Button)sender;
                op_value = bu.Text;
                txt_value = double.Parse(textBox1.Text);
                bool_value = true;
                label1.Text = txt_value + "" + op_value;
        }

        private void Equal_button_click(object sender, EventArgs e)
        {
            switch (op_value)
            {
                case "+":
                    textBox1.Text = (txt_value + double.Parse(textBox1.Text)).ToString();
                    break;
                      
                case "-":
                    textBox1.Text = (txt_value - double.Parse(textBox1.Text)).ToString();
                 break;
               
                case "*":
                 textBox1.Text = (txt_value * double.Parse(textBox1.Text)).ToString();
                 break;

               case "/":
                 textBox1.Text = (txt_value / double.Parse(textBox1.Text)).ToString();
                 break;
            }
        }      
    }
}

Description:-
  • Here I have putted all numeric button such as 0,1,2,3,4,5,6,7,8, . in Numeric_button_click Event Handler section.So You have to go each numeric Button's properties -->Events --> Set Click =Numeric_button_Click.
  • Here i have putted Operator button such as +,-,*,/ in operator_button_Click  Event Handler-->So go each operator Button's properties -->Events --> Set Click =operator_button_Click.
  • Similarly others also putted in respective event handlers,You can see it in above c# coding.
Step 4:- Now Run the Application (press F5)-->you will see following output:-


output

Now i am going to create a setup file of above application in visual studio 2010 and 2012 both.But i will show you "How to create setup file in visual studio 2012"only.Because i have already created setup file in visual studio 2010 so you have to follow same setup from here

There are some steps to create setup file in visual studio 2012 as given below:-
Step 1 :- First open this project in your visual studio-->Open Solution Explorer -->Right click on project (your Application) --> Press Publish as shown below:-


publish_project

Step 2  :- Now Create a New Folder (calculator) on Your Desktop --> Click Browse Button --> select your setup file path on Your Desktop's Folder (Calculator) -->Proceed With Next Button as shown below:-


path

Step 3 :- Now Select From CD-ROM or DVD-ROM 's Radio Button -->and Proceed With Next Button as shown below:-


proceed_next

Step 4 :- Now you can select corresponding Radio Button if you want to receive update alert or not of your setup as shown below -->Press Finish Button -->Done. 



Step 5 :- Now Open your Desktop Folder (calculator) -->You will see three files --> Install Setup.exe file as shown below:-


install

Step 6 :- Now click start button --> Open your installed calculator application( or open it by Desktop icon) as shown below:-


perform_operations

In this Post I have create two different setup file for this Calculator application.You can download it from the below link.
  1. First By Visual studio 2010
  2. Second By Visual studio 2012 
For More...
  1. How to Build Form Filling application in asp.net like IBPS
  2. How to implement Trigger concepts in asp.net application
  3. How to implement caching concepts in asp.net application
  4. How to implement web services in asp.net application
  5. How to implement wcf concepts in asp.net application
  6. How to implement cookies concepts in asp.net website
  7. How to implement all web form controls in as.net application
  8. How to implement windows authentication concepts in asp.net
  9. How to understand the real life examples of oops concepts
  10. How to host asp.net website on server free
  11. How to implement page life cycle events concepts in asp.net
  12. How to create dll file and use it in .NET application
  13. How to use secure login page in asp.net with example
  14. How to Add and verify Captcha image in 3 tier architecture in asp.net
  15. How to use virtual keyboard in asp.net for security purpose
  16. How to implement hashing concepts in asp.net
  17. Learn complete .Net Interview Questions and answers for job seekers
Attention :-
  • If you are using window xp/vista /7 then you will required .Net Framework 4.5.You can download it from here  and install it on your system. Otherwise setup automatically download this framework when you will install it.
  • If you are using window 8 then you will not required this framework because it is already installed.
  • Please share this post with your friends if this is helpful for you.If any problem comment it.
VS2010 Setup file          VS2012 Setup file                  Calculator Application
 Download                 Download                    Download 

1 comment:

  1. 1 the name 'label1' does not exist in the current context

    ReplyDelete

Powered by Blogger.