|
|
|
|
|
namespace calculator { public partial class Form1 : Form { public static string op; public static double n1; public Form1() { InitializeComponent(); } private void buttonH9_Click(object sender, EventArgs e) { textBox1.Text += "1"; } private void buttonH10_Click(object sender, EventArgs e) { textBox1.Text += "2"; } private void buttonH11_Click(object sender, EventArgs e) { textBox1.Text += "3"; } private void buttonH5_Click(object sender, EventArgs e) { textBox1.Text += "4"; } private void buttonH6_Click(object sender, EventArgs e) { textBox1.Text += "5"; } private void buttonH7_Click(object sender, EventArgs e) { textBox1.Text += "6"; } private void buttonH1_Click(object sender, EventArgs e) { textBox1.Text += "7"; } private void buttonH2_Click(object sender, EventArgs e) { textBox1.Text += "8"; } private void buttonH3_Click(object sender, EventArgs e) { textBox1.Text += "9"; } private void buttonH13_Click(object sender, EventArgs e) { textBox1.Text += "0"; } private void buttonH17_Click(object sender, EventArgs e) { textBox1.Text = ""; } private void buttonH15_Click(object sender, EventArgs e) { try { switch (op) { case "/": textBox1.Text = Convert.ToString(n1 / Convert.ToDouble(textBox1.Text)); break; case "*": textBox1.Text = Convert.ToString(n1 * Convert.ToDouble(textBox1.Text)); break; case "+": textBox1.Text = Convert.ToString(n1 + Convert.ToDouble(textBox1.Text)); break; case "-": textBox1.Text = Convert.ToString(n1 - Convert.ToDouble(textBox1.Text)); break; } } catch { } } private void buttonH4_Click(object sender, EventArgs e) { try { op = "/"; n1 = Convert.ToDouble(textBox1.Text); textBox1.Text = ""; } catch { } } private void buttonH8_Click(object sender, EventArgs e) { try { op = "*"; n1 = Convert.ToDouble(textBox1.Text); textBox1.Text = ""; } catch { } } private void buttonH12_Click(object sender, EventArgs e) { try { op = "-"; n1 = Convert.ToDouble(textBox1.Text); textBox1.Text = ""; } catch { } } private void buttonH16_Click(object sender, EventArgs e) { try { op = "+"; n1 = Convert.ToDouble(textBox1.Text); textBox1.Text = ""; } catch { } } private void buttonH14_Click(object sender, EventArgs e) { textBox1.Text += "."; } } }
|
||
|
+
نوشته شده در چهارشنبه هفتم دی 1390ساعت 11:41 توسط رضا اکبری
|
|
||