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 ....