Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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 WindowsFormsApplication2
- {
- public partial class Form1 : Form
- {
- private int c = 0;
- private string f,g;
- public Form1()
- {
- InitializeComponent();
- }
- private void button_text(string a)
- {
- if (c == 1)
- {
- textBox1.Text = a;
- }
- else {
- textBox1.Text = textBox1.Text + a;
- }
- }
- private void button1_Click(object sender, EventArgs e)
- {
- c++;
- button_text("1");
- }
- private void textBox1_TextChanged(object sender, EventArgs e)
- {
- }
- private void button2_Click(object sender, EventArgs e)
- {
- c++;
- button_text("2");
- }
- private void button3_Click(object sender, EventArgs e)
- {
- c++;
- button_text("3");
- }
- private void button4_Click(object sender, EventArgs e)
- {
- c++;
- button_text("4");
- }
- private void button5_Click(object sender, EventArgs e)
- {
- c++;
- button_text("5");
- }
- private void button6_Click(object sender, EventArgs e)
- {
- c++;
- button_text("6");
- }
- private void button7_Click(object sender, EventArgs e)
- {
- c++;
- button_text("7");
- }
- private void button8_Click(object sender, EventArgs e)
- {
- c++;
- button_text("8");
- }
- private void button9_Click(object sender, EventArgs e)
- {
- c++;
- button_text("9");
- }
- private void button10_Click(object sender, EventArgs e)
- {
- c++;
- button_text("0");
- }
- private void button15_Click(object sender, EventArgs e)
- {
- c = 0;
- if (g == "+") {
- textBox1.Text = (Convert.ToInt32(f) + Convert.ToInt32(textBox1.Text)).ToString();
- }
- else if (g == "-") {
- textBox1.Text = (Convert.ToInt32(f) - Convert.ToInt32(textBox1.Text)).ToString();
- }
- else if (g == "*")
- {
- textBox1.Text = (Convert.ToInt32(f) * Convert.ToInt32(textBox1.Text)).ToString();
- }
- else if (g == "/")
- {
- textBox1.Text = (double.Parse(f)/double.Parse(textBox1.Text)).ToString();
- }
- }
- private void button11_Click(object sender, EventArgs e)
- {
- g = "+";
- c = 0;
- f = textBox1.Text;
- }
- private void button12_Click(object sender, EventArgs e)
- {
- g = "-";
- c = 0;
- f = textBox1.Text;
- }
- private void button13_Click(object sender, EventArgs e)
- {
- g = "*";
- c = 0;
- f = textBox1.Text;
- }
- private void button14_Click(object sender, EventArgs e)
- {
- g = "/";
- c = 0;
- f = textBox1.Text;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement