.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> Visual Studio >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Arithmetic operation using Combo box(c#.net)

Posted By:laptop charles       Posted Date: December 21, 2010    Points: 15    Category: Visual Studio    URL: http://www.dotnetspark.com  

It has using combo box and three textbox.Add four operation to combo box and then using selectedItem.Type the number in that two textbox. then select one operator.it will give the result.
 

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 combo_box
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
       
        int x, y, z;
      
              
         
  

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            x = int.Parse(a.Text);

            y = int.Parse(b.Text);
            if (comboBox1.SelectedItem.ToString() == "Add")
            {
                       
                z = x + y;
                c.Text = z.ToString();

            }
            else if (comboBox1.SelectedItem.ToString() == "Sub")
            {

                z = x -y;
                c.Text = z.ToString();

            }
            else if (comboBox1.SelectedItem.ToString() == "Mul")
            {

                z = x * y;
                c.Text = z.ToString();

            }
            else if (comboBox1.SelectedItem.ToString() == "Div")
            {

                z = x / y;
                c.Text = z.ToString();

            }


        }

        

    }
}

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend