Würden Sie gerne auf diese Nachricht reagieren? Erstellen Sie einen Account in wenigen Klicks oder loggen Sie sich ein, um fortzufahren.

Taschenrechner

Nach unten

Taschenrechner Empty Taschenrechner

Beitrag von Zwieback Mo März 03, 2014 9:38 pm

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 Test
{
   public partial class fMain : Form
   {
       public string tb_inhalt1;
       public string tb_inhalt2;
       public string rechnen;

       public fMain()
       {
           InitializeComponent();
       }


       private void btn1_Click(object sender, EventArgs e)
       {
           if (rechnen != "")
           {
               tb_inhalt2 = txtB.Text + "1";
               txtB.Text = tb_inhalt2;
           }
           
           else
           {
               tb_inhalt1 = txtB.Text + "1";
               txtB.Text = tb_inhalt1;
           }
       }

       private void btn2_Click(object sender, EventArgs e)
       {
           if (rechnen != "")
           {
               tb_inhalt2 = txtB.Text + "2";
               txtB.Text = tb_inhalt2;
           }

           else
           {
               tb_inhalt1 = txtB.Text + "2";
               txtB.Text = tb_inhalt1;
           }
       }

       private void btn3_Click(object sender, EventArgs e)
       {
           if (rechnen != "")
           {
               tb_inhalt2 = txtB.Text + "3";
               txtB.Text = tb_inhalt2;
           }

           else
           {
               tb_inhalt1 = txtB.Text + "3";
               txtB.Text = tb_inhalt1;
           }
       }

       private void btn4_Click(object sender, EventArgs e)
       {
           if (rechnen != "")
           {
               tb_inhalt2 = txtB.Text + "4";
               txtB.Text = tb_inhalt2;
           }

           else
           {
               tb_inhalt1 = txtB.Text + "4";
               txtB.Text = tb_inhalt1;
           }
       }

       private void btn5_Click(object sender, EventArgs e)
       {
           if (rechnen != "")
           {
               tb_inhalt2 = txtB.Text + "5";
               txtB.Text = tb_inhalt2;
           }

           else
           {
               tb_inhalt1 = txtB.Text + "5";
               txtB.Text = tb_inhalt1;
           }
       }

       private void btn6_Click(object sender, EventArgs e)
       {
           if (rechnen != "")
           {
               tb_inhalt2 = txtB.Text + "6";
               txtB.Text = tb_inhalt2;
           }

           else
           {
               tb_inhalt1 = txtB.Text + "6";
               txtB.Text = tb_inhalt1;
           }
       }

       private void btn7_Click(object sender, EventArgs e)
       {
           if (rechnen != "")
           {
               tb_inhalt2 = txtB.Text + "7";
               txtB.Text = tb_inhalt2;
           }

           else
           {
               tb_inhalt1 = txtB.Text + "7";
               txtB.Text = tb_inhalt1;
           }
       }

       private void btn8_Click(object sender, EventArgs e)
       {
           if (rechnen != "")
           {
               tb_inhalt2 = txtB.Text + "8";
               txtB.Text = tb_inhalt2;
           }

           else
           {
               tb_inhalt1 = txtB.Text + "8";
               txtB.Text = tb_inhalt1;
           }
       }

       private void btn9_Click(object sender, EventArgs e)
       {
           if (rechnen != "")
           {
               tb_inhalt2 = txtB.Text + "9";
               txtB.Text = tb_inhalt2;
           }

           else
           {
               tb_inhalt1 = txtB.Text + "9";
               txtB.Text = tb_inhalt1;
           }
       }

       private void btn0_Click(object sender, EventArgs e)
       {
           if (rechnen != "")
           {
               tb_inhalt2 = txtB.Text + "0";
               txtB.Text = tb_inhalt2;
           }

           else
           {
               tb_inhalt1 = txtB.Text + "0";
               txtB.Text = tb_inhalt1;
           }
       }

       private void btnPlus_Click(object sender, EventArgs e)
       {
           rechnen = "+";
           tb_inhalt1 = txtB.Text;
           txtB.Text = "";
           lblZahl.Text = tb_inhalt1 + rechnen;
       }

       private void btnMinus_Click(object sender, EventArgs e)
       {
           rechnen = "-";
           tb_inhalt1 = txtB.Text;
           txtB.Text = "";
           lblZahl.Text = tb_inhalt1 + rechnen;
       }

       private void btnMal_Click(object sender, EventArgs e)
       {
           rechnen = "*";
           tb_inhalt1 = txtB.Text;
           txtB.Text = "";
           lblZahl.Text = tb_inhalt1 + rechnen;
       }

       private void btnGeteilt_Click(object sender, EventArgs e)
       {
           rechnen = "/";
           tb_inhalt1 = txtB.Text;
           txtB.Text = "";
           lblZahl.Text = tb_inhalt1 + rechnen;
           
       }

       private void btnGleich_Click(object sender, EventArgs e)
       {

           if (rechnen == "+")
           {
               txtB.Text = Convert.ToString(Convert.ToInt32(tb_inhalt1) + Convert.ToInt32(tb_inhalt2));
           }

           else if (rechnen == "-")
           {
               txtB.Text = Convert.ToString(Convert.ToInt32(tb_inhalt1) - Convert.ToInt32(tb_inhalt2));
           }

           else if (rechnen == "*")
           {
               txtB.Text = Convert.ToString(Convert.ToInt32(tb_inhalt1) * Convert.ToInt32(tb_inhalt2));
           }
           else
           {
               txtB.Text = Convert.ToString(Convert.ToInt32(tb_inhalt1) / Convert.ToInt32(tb_inhalt2));
           }

           lblZahl.Text = tb_inhalt1 + rechnen + tb_inhalt2 + "=";
       }

       private void btnClear_Click(object sender, EventArgs e)
       {
           txtB.Text = "";
           lblZahl.Text = "";
       }

       private void fMain_Load(object sender, EventArgs e)
       {

       }

       private void txtB_MouseHover(object sender, EventArgs e)
       {
           txtB.BackColor = Color.Lime;
       }

       private void txtB_MouseLeave(object sender, EventArgs e)
       {
           txtB.BackColor = Color.White;
       }

       


   }
}

Taschenrechner Unbena10

Zwieback
Admin

Anzahl der Beiträge : 33
Anmeldedatum : 03.03.14

https://htmlcssanleitungen.forenverzeichnis.com

Nach oben Nach unten

Nach oben


 
Befugnisse in diesem Forum
Sie können in diesem Forum nicht antworten