April 27, 2012

C# RadioButton and Calculator



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

        private void button1_Click(object sender, EventArgs e)
        {
            int tx1,tx2,rs=0;

            tx1=int.Parse(textBox1.Text);
            tx2=int.Parse(textBox2.Text);



            if (radioButton1.Checked)
                rs = tx1 + tx2;
            else if (radioButton2.Checked)
                rs = tx1 - tx2;
            else if (radioButton3.Checked)
                rs = tx1 * tx2;
            else if (radioButton4.Checked)
                rs = tx1 / tx2;

            textBox3.Text = rs.ToString();
          }

     
    }
}

No comments:

Post a Comment