Guest User

Untitled

a guest
Jan 19th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.86 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9.  
  10. namespace WindowsFormsApplication4
  11. {
  12. public partial class Form1 : Form
  13. {
  14. public Form1()
  15. {
  16. InitializeComponent();
  17. }
  18.  
  19. private void button1_Click(object sender, EventArgs e)
  20. {
  21. if (comboBox1.Text=="+")
  22. {
  23. double wynik=double.Parse(textBox1.Text)+double.Parse(textBox2.Text);
  24. textBox3.Visible = true;
  25. textBox3.Text = wynik.ToString();
  26.  
  27.  
  28. }
  29. else if(comboBox1.Text=="-")
  30. {
  31. double wynik=double.Parse(textBox1.Text)-double.Parse(textBox2.Text);
  32. textBox3.Visible = true;
  33. textBox3.Text = wynik.ToString();
  34. }
  35. else if(comboBox1.Text=="*")
  36. {
  37. double wynik=double.Parse(textBox1.Text)*double.Parse(textBox2.Text);
  38. textBox3.Visible = true;
  39. textBox3.Text = wynik.ToString();
  40. }
  41. else if (comboBox1.Text == "/")
  42. {
  43. double wynik = double.Parse(textBox1.Text) / double.Parse(textBox2.Text);
  44. textBox3.Visible = true;
  45. textBox3.Text = wynik.ToString();
  46. }
  47.  
  48. }
  49.  
  50.  
  51. private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
  52. {
  53. textBox2.Visible = true;
  54.  
  55. }
  56.  
  57. private void textBox2_TextChanged(object sender, EventArgs e)
  58. {
  59. try
  60. {
  61. int a;
  62. bool c = int.TryParse(textBox2.Text, out a);
  63. if (c)
  64. {
  65.  
  66. button1.Visible = true;
  67. }
  68. }
  69. catch
  70. {
  71. }
  72. }
  73.  
  74. private void textBox3_TextChanged(object sender, EventArgs e)
  75. {
  76. textBox3.Enabled = false;
  77. }
  78.  
  79. private void textBox1_TextChanged(object sender, EventArgs e)
  80. {
  81.  
  82. }
  83.  
  84. private void textBox1_KeyDown(object sender, KeyEventArgs e)
  85. {
  86.  
  87. try
  88. {
  89.  
  90. int i;
  91. bool b = int.TryParse(textBox1.Text, out i);
  92.  
  93.  
  94. if (b)
  95. {
  96.  
  97. textBox1.ForeColor = Color.Blue;
  98. if (e.KeyCode == Keys.Return)
  99. {
  100. comboBox1.Visible = true;
  101. comboBox1.Focus();
  102. }
  103.  
  104.  
  105. }
  106. else
  107. textBox1.ForeColor = Color.Blue;
  108.  
  109. }
  110. catch (ArithmeticException)
  111. {
  112. }
  113.  
  114. }
  115.  
  116. private void comboBox1_KeyDown(object sender, KeyEventArgs e)
  117. {
  118.  
  119. if(e.KeyCode==Keys.Return)
  120. {
  121. textBox2.Visible=true;
  122. textBox2.Focus();
  123. }
  124. else if (e.KeyCode == Keys.Escape)
  125. {
  126. comboBox1.Visible = false;
  127. textBox1.Focus();
  128. }
  129. }
  130.  
  131. private void textBox2_KeyDown(object sender, KeyEventArgs e)
  132. {
  133. try
  134. {
  135. int a;
  136. bool c = int.TryParse(textBox2.Text, out a);
  137. if (c)
  138. {
  139. textBox1.ForeColor = Color.Blue;
  140. if (e.KeyCode == Keys.Return)
  141. {
  142. button1.Visible = true;
  143. button1.Focus();
  144. }
  145. else if (e.KeyCode == Keys.Escape)
  146. {
  147. textBox2.Visible = false;
  148. comboBox1.Focus();
  149. }
  150.  
  151.  
  152.  
  153. }
  154. }
  155. catch
  156. {
  157. }
  158. }
  159.  
  160. private void button1_KeyDown(object sender, KeyEventArgs e)
  161. {
  162.  
  163. if (e.KeyCode == Keys.Return)
  164. {
  165. textBox3.Visible = true;
  166. textBox3.Focus();
  167. }
  168. else if (e.KeyCode == Keys.Escape)
  169. {
  170. button1.Visible = false;
  171. textBox2.Focus();
  172. textBox3.Visible = false;
  173.  
  174. }
  175. }
  176.  
  177. private void textBox3_KeyDown(object sender, KeyEventArgs e)
  178. {
  179.  
  180. }
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192. }
  193. }
Add Comment
Please, Sign In to add comment