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.Windows.Forms;
- namespace WindowsFormsApplication4
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- if (comboBox1.Text=="+")
- {
- double wynik=double.Parse(textBox1.Text)+double.Parse(textBox2.Text);
- textBox3.Visible = true;
- textBox3.Text = wynik.ToString();
- }
- else if(comboBox1.Text=="-")
- {
- double wynik=double.Parse(textBox1.Text)-double.Parse(textBox2.Text);
- textBox3.Visible = true;
- textBox3.Text = wynik.ToString();
- }
- else if(comboBox1.Text=="*")
- {
- double wynik=double.Parse(textBox1.Text)*double.Parse(textBox2.Text);
- textBox3.Visible = true;
- textBox3.Text = wynik.ToString();
- }
- else if (comboBox1.Text == "/")
- {
- double wynik = double.Parse(textBox1.Text) / double.Parse(textBox2.Text);
- textBox3.Visible = true;
- textBox3.Text = wynik.ToString();
- }
- }
- private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
- {
- textBox2.Visible = true;
- }
- private void textBox2_TextChanged(object sender, EventArgs e)
- {
- try
- {
- int a;
- bool c = int.TryParse(textBox2.Text, out a);
- if (c)
- {
- button1.Visible = true;
- }
- }
- catch
- {
- }
- }
- private void textBox3_TextChanged(object sender, EventArgs e)
- {
- textBox3.Enabled = false;
- }
- private void textBox1_TextChanged(object sender, EventArgs e)
- {
- }
- private void textBox1_KeyDown(object sender, KeyEventArgs e)
- {
- try
- {
- int i;
- bool b = int.TryParse(textBox1.Text, out i);
- if (b)
- {
- textBox1.ForeColor = Color.Blue;
- if (e.KeyCode == Keys.Return)
- {
- comboBox1.Visible = true;
- comboBox1.Focus();
- }
- }
- else
- textBox1.ForeColor = Color.Blue;
- }
- catch (ArithmeticException)
- {
- }
- }
- private void comboBox1_KeyDown(object sender, KeyEventArgs e)
- {
- if(e.KeyCode==Keys.Return)
- {
- textBox2.Visible=true;
- textBox2.Focus();
- }
- else if (e.KeyCode == Keys.Escape)
- {
- comboBox1.Visible = false;
- textBox1.Focus();
- }
- }
- private void textBox2_KeyDown(object sender, KeyEventArgs e)
- {
- try
- {
- int a;
- bool c = int.TryParse(textBox2.Text, out a);
- if (c)
- {
- textBox1.ForeColor = Color.Blue;
- if (e.KeyCode == Keys.Return)
- {
- button1.Visible = true;
- button1.Focus();
- }
- else if (e.KeyCode == Keys.Escape)
- {
- textBox2.Visible = false;
- comboBox1.Focus();
- }
- }
- }
- catch
- {
- }
- }
- private void button1_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Return)
- {
- textBox3.Visible = true;
- textBox3.Focus();
- }
- else if (e.KeyCode == Keys.Escape)
- {
- button1.Visible = false;
- textBox2.Focus();
- textBox3.Visible = false;
- }
- }
- private void textBox3_KeyDown(object sender, KeyEventArgs e)
- {
- }
- }
- }
Add Comment
Please, Sign In to add comment