After a morning, a calculator finally formed ....

Source: Internet
Author: User

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 WindowsFormsApplication1 {public partial class Form1:form {double A;         int b = 1;           string C; Public Form1 () {

InitializeComponent (); }

private void Form1_Load (object sender, EventArgs e) {

}

private void textBox1_TextChanged (object sender, EventArgs e) {

}

private void Btnnum7_click (object sender, EventArgs e) {if (b = = 1) {Tex                 Tbox1.text = "";             b = 2; } TextBox1.Text + = "7";

}

private void Btnnum8_click (object sender, EventArgs e) {if (b = = 1) {Tex                 Tbox1.text = "";             b = 2; } TextBox1.Text + = "8";

}

private void Btnnum9_click (object sender, EventArgs e) {if (b = = 1) {Tex                 Tbox1.text = "";             b = 2; } TextBox1.Text + = "9";

}

private void Btnnum4_click (object sender, EventArgs e) {if (b = = 1) {Tex                 Tbox1.text = "";             b = 2; } TextBox1.Text + = "4";

}

private void Btnnum5_click (object sender, EventArgs e) {if (b = = 1) {Tex                 Tbox1.text = "";             b = 2; } TextBox1.Text + = "5";

}

private void Btnnum6_click (object sender, EventArgs e) {if (b = = 1) {Tex                 Tbox1.text = "";             b = 2; } TextBox1.Text + = "6";

}

        private void Btnnum1_click (object sender, EventArgs e)          {            if (b = = 1)          {           TEXTB Ox1. Text = "";              b=2;     & nbsp;             }                     textbox1.text+= "1";  & nbsp;             

private void Btnnum2_click (object sender, EventArgs e) {if (b = = 1) {Tex                 Tbox1.text = "";             b = 2; } TextBox1.Text + = "2";

}

private void Btnnum3_click (object sender, EventArgs e) {if (b = = 1) {Tex                 Tbox1.text = "";             b = 2; } TextBox1.Text + = "3";

}

        private void Btnzero_click (object sender, EventArgs e)    & nbsp;    {                             if (b = = 1)                  {                     TextBox1.Text = "";                      B = 2;                }                  TextBox1.Text + = "0";                 if (c = = "/")                  {                     TextBox1.Text = "Error";                      MessageBox.Show ("Divisor cannot be zero");                }                 

}

private void btnAdd_Click (object sender, EventArgs e) {b = 1; A = double.             Parse (TextBox1.Text);               c = "+"; }

private void Btnsub_click (object sender, EventArgs e) {b = 1; A = double.             Parse (TextBox1.Text);               c = "-"; }

private void Btnmul_click (object sender, EventArgs e) {b = 1; A = double.             Parse (TextBox1.Text);            c = "*"; }

private void Btndiv_click (object sender, EventArgs e) {b = 1; A = double.             Parse (TextBox1.Text);           c = "/"; }

private void Btnsqrt_click (object sender, EventArgs e) {b = 1; A = double.             Parse (TextBox1.Text);              c = "sqrt"; }

        private void Btnresult_click (object sender, EventArgs e)          {            switch (c)          {          & nbsp;    case "+": A = a + double. Parse (TextBox1.Text); break;        Case "-": A = a-double. Parse (TextBox1.Text); break;       Case "*": a = A * double. Parse (TextBox1.Text); break;        case "/": A = a/double. Parse (TextBox1.Text); break;                 case " Sqrt ": a = Math.sqrt (a); break;                            }                                            TextBox1.Text = a + "";         b =1;     }

private void Btnclear_click (object sender, EventArgs e) {TextBox1.Text = "0"; }         }     }

After a morning, a calculator finally formed ....

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.