lunes, 22 de julio de 2013

Cadenas, Codigos En C# , C Sharp


Crear una calculadora utilizando el lenguaje de programación visual estudio C Sharp C#  utilizando Windows Form.codigos fuentes de una calculadora basica utilizando tipos herramienta de formulario.


namespace calculador{
    public partial class Form1 : Form{
        public Form1()
        {

   InitializeComponent();
        }


        string n; float r;
        private void btn1_Click(object sender, EventArgs e){
            n = "1";

            if (lbOp.Text == ""){
                lb1.Text = lb1.Text + n.ToString();
            }
            else{
                lb2.Text = lb2.Text + n.ToString();
            }
        }
        private void btn0_Click(object sender, EventArgs e){
            n = "0";
            if (lbOp.Text==""){
                lb1.Text = lb1.Text + n.ToString();
            }
            else{        
                lb2.Text = lb2.Text + n.ToString();
            }
        }
        private void btn2_Click(object sender, EventArgs e){
            n = "2";
            if (lbOp.Text == ""){
                lb1.Text = lb1.Text + n.ToString();
            }
            else {
                lb2.Text = lb2.Text + n.ToString(); }
        }
        private void btn3_Click(object sender, EventArgs e)
        {
            n = "3";
            if (lbOp.Text == ""){
                lb1.Text = lb1.Text + n.ToString();
            }
            else
            {
                lb2.Text = lb2.Text + n.ToString();       }
        }
        private void btn4_Click(object sender, EventArgs e)
        {
            n = "4";
            if (lbOp.Text == "")  {
                lb1.Text = lb1.Text + n.ToString();
            }
            else
            {
                lb2.Text = lb2.Text + n.ToString();}
        }
        private void btn5_Click(object sender, EventArgs e)
        {
            n = "5";
            if (lbOp.Text == "")  {
                lb1.Text = lb1.Text + n.ToString();        }
            else   {
                lb2.Text = lb2.Text + n.ToString();    }
        }
        private void btn6_Click(object sender, EventArgs e)
        {
            n = "6";
            if (lbOp.Text == "")  {
                lb1.Text = lb1.Text + n.ToString();
            }
            else   {
                lb2.Text = lb2.Text + n.ToString();  }
        }
        private void btn7_Click(object sender, EventArgs e)
        {
            n = "7";
            if (lbOp.Text == ""){
                lb1.Text = lb1.Text + n.ToString();
            }
            else{
                lb2.Text = lb2.Text + n.ToString();           }
        }
        private void btn8_Click(object sender, EventArgs e)
        {
            n = "8";
            if (lbOp.Text == ""){
                lb1.Text = lb1.Text + n.ToString();
            }
            else{
                lb2.Text = lb2.Text + n.ToString();       }
        }
        private void btn9_Click(object sender, EventArgs e)
        {
            n = "9";
            if (lbOp.Text == ""){
                lb1.Text = lb1.Text + n.ToString();
            }
            else{
                lb2.Text = lb2.Text + n.ToString();
            }
        }
        private void btnSumar_Click(object sender, EventArgs e)
        {
            n = "+";
            lbOp.Text = n.ToString();
        }
        private void btnResta_Click(object sender, EventArgs e)
        {
            n = "-";
            lbOp.Text = n.ToString();
        }
        private void btnMultipl_Click(object sender, EventArgs e)
        {
            n = "*";
            lbOp.Text = n.ToString();
        }
        private void btnDivision_Click(object sender, EventArgs e)
        {
            n = "/";
            lbOp.Text = n.ToString();
        }
        private void btnIgual_Click(object sender, EventArgs e)
        {
            string a="+";
            if (lbOp.Text == a)
            {
                r = int.Parse(lb1.Text) + int.Parse(lb2.Text);
                txtRes.Text = r.ToString();
            }
            string b = "-";
            if (lbOp.Text == b)
            {
                r = int.Parse(lb1.Text) - int.Parse(lb2.Text);
                txtRes.Text = r.ToString();
            }
            string c = "*";
            if (lbOp.Text == c)
            {
                r = int.Parse(lb1.Text) * int.Parse(lb2.Text);
                txtRes.Text = r.ToString();
            }
            string d = "/";
            if (lbOp.Text == d)
            {
                r = float.Parse(lb1.Text) / float.Parse(lb2.Text);
                txtRes.Text = r.ToString();  }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            label4.Text = "¡¡---BYTE BYTE---!!";
            {
                MessageBox.Show("se cerrara la aplicacion");
                Application.Exit();    }
        }
        private void btnborrar_Click(object sender, EventArgs e)
        {
            lb1.Text = ""; lb2.Text = "";    lbOp.Text = "";    txtRes.Text = ""; }
        private void button8_Click(object sender, EventArgs e)
        {
            int a;
            if (lbOp.Text == ""){
                if (lb1.Text == "0"){
                    lb1.Text = "";
                }
                else {
                    a = int.Parse(lb1.Text) / 10;
                    lb1.Text = a.ToString();
                }
            }
           else
                if (lb2.Text == "0"){
                    lb2.Text = "";
                }
                else{
                    a = int.Parse(lb2.Text) / 10;
                    lb2.Text = a.ToString();
                }
        }

No hay comentarios:

Publicar un comentario

bueno se acepta recomendaciones y criticas positivas y e persona que si sabe de programacion o interesado en aprender ,no cualquiera que esta solo buscando codigos para copy y paste

LinkWithin

Related Posts Plugin for WordPress, Blogger...