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 WindowsFormsApplication1
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void textBox3_TextChanged(object sender, EventArgs e)
- {
- }
- private void button1_Click(object sender, EventArgs e)
- {
- int a = Convert.ToInt32(textBox1.Text);
- int b = Convert.ToInt32(textBox2.Text);
- textBox3.Text = Convert.ToString(a + b);
- label2.Text = "+";
- }
- private void button2_Click(object sender, EventArgs e)
- {
- int a = Convert.ToInt32(textBox1.Text);
- int b = Convert.ToInt32(textBox2.Text);
- textBox3.Text = Convert.ToString(a - b);
- label2.Text = "-";
- }
- private void button3_Click(object sender, EventArgs e)
- {
- decimal a = Convert.ToDecimal(textBox1.Text);
- decimal b = Convert.ToDecimal(textBox2.Text);
- textBox3.Text = Convert.ToString(a * b);
- label2.Text = "*";
- }
- private void button4_Click(object sender, EventArgs e)
- {
- decimal a = Convert.ToDecimal(textBox1.Text);
- decimal b = Convert.ToDecimal(textBox2.Text);
- textBox3.Text = Convert.ToString(a / b);
- label2.Text = "/";
- }
- private void button5_Click(object sender, EventArgs e)
- {
- textBox1.Clear();
- textBox2.Clear();
- textBox3.Clear();
- }
- private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
- {
- char a = e.KeyChar;
- if (!Char.IsDigit(a) && a != 8 && a != 42)
- {
- e.Handled = true;
- }
- }
- private void textBox2_KeyPress(object sender, KeyPressEventArgs e)
- {
- char a = e.KeyChar;
- if (!Char.IsDigit(a) && a != 8 && a != 42)
- {
- e.Handled = true;
- }
- }
- private void textBox3_KeyPress(object sender, KeyPressEventArgs e)
- {
- char a = e.KeyChar;
- if (!Char.IsDigit(a) && a != 8 && a != 42)
- {
- e.Handled = true;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement