Guest User

Untitled

a guest
Oct 18th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.22 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 WindowsFormsApplication1
  11. {
  12. public partial class Form1 : Form
  13. {
  14. bool plus = false;
  15. bool minus = false;
  16. bool multiply = false;
  17. bool divide = false;
  18. bool equal = false;
  19. public Form1()
  20. {
  21. InitializeComponent();
  22. }
  23.  
  24. private void button1_Click(object sender, EventArgs e)
  25. {
  26. CheckifEqual();
  27. if (equal)
  28. {
  29. textBox1.Text = "";
  30. equal = false;
  31. }
  32. textBox1.Text = textBox1.Text + "1";
  33. }
  34.  
  35. private void CheckifEqual()
  36. {
  37. if (equal)
  38. {
  39. textBox1.Text = "";
  40. equal = false;
  41. }
  42. }
  43.  
  44. private void button2_Click(object sender, EventArgs e)
  45. {
  46. CheckifEqual();
  47. textBox1.Text = textBox1.Text + "2";
  48. }
  49.  
  50. private void button3_Click(object sender, EventArgs e)
  51. {
  52. CheckifEqual();
  53. textBox1.Text = textBox1.Text + "3";
  54. }
  55.  
  56. private void button4_Click(object sender, EventArgs e)
  57. {
  58. CheckifEqual();
  59. textBox1.Text = textBox1.Text + "4";
  60. }
  61.  
  62. private void button5_Click(object sender, EventArgs e)
  63. {
  64. CheckifEqual();
  65. textBox1.Text = textBox1.Text + "5";
  66. }
  67.  
  68. private void button6_Click(object sender, EventArgs e)
  69. {
  70. CheckifEqual();
  71. textBox1.Text = textBox1.Text + "6";
  72. }
  73.  
  74. private void button7_Click(object sender, EventArgs e)
  75. {
  76. CheckifEqual();
  77. textBox1.Text = textBox1.Text + "7";
  78. }
  79.  
  80. private void button8_Click(object sender, EventArgs e)
  81. {
  82. CheckifEqual();
  83. textBox1.Text = textBox1.Text + "8";
  84. }
  85.  
  86. private void button9_Click(object sender, EventArgs e)
  87. {
  88. CheckifEqual();
  89. textBox1.Text = textBox1.Text + "9";
  90. }
  91.  
  92. private void button10_Click(object sender, EventArgs e)
  93. {
  94. CheckifEqual();
  95. textBox1.Text = textBox1.Text + "0";
  96. }
  97.  
  98. private void button12_Click(object sender, EventArgs e)
  99. {
  100. CheckifEqual();
  101. if (textBox1.Text.Contains("."))
  102. {
  103. return;
  104. }
  105. else
  106. {
  107. textBox1.Text = textBox1.Text + ".";
  108. }
  109. }
  110.  
  111. private void button15_Click(object sender, EventArgs e)
  112. {
  113. if (textBox1.Text == "")
  114. {
  115. return;
  116. }
  117. else
  118. {
  119. plus = true;
  120. textBox1.Tag = textBox1.Text;
  121. textBox1.Text = "";
  122. }
  123. }
  124.  
  125. private void button14_Click(object sender, EventArgs e)
  126. {
  127. equal = true;
  128. if (plus)
  129. {
  130. decimal dec = Convert.ToDecimal(textBox1.Tag) + Convert.ToDecimal(textBox1.Text);
  131. textBox1.Text = dec.ToString();
  132. }
  133. if (multiply)
  134. {
  135. decimal dec = Convert.ToDecimal(textBox1.Tag) * Convert.ToDecimal(textBox1.Text);
  136. textBox1.Text = dec.ToString();
  137. }
  138. if (minus)
  139. {
  140. decimal dec = Convert.ToDecimal(textBox1.Tag) - Convert.ToDecimal(textBox1.Text);
  141. textBox1.Text = dec.ToString();
  142. }
  143. if (divide)
  144. {
  145. decimal dec = Convert.ToDecimal(textBox1.Tag) / Convert.ToDecimal(textBox1.Text);
  146. textBox1.Text = dec.ToString();
  147. }
  148. }
  149.  
  150. private void button16_Click(object sender, EventArgs e)
  151. {
  152. if (textBox1.Text == "")
  153. {
  154. return;
  155. }
  156. else
  157. {
  158. minus = true;
  159. textBox1.Tag = textBox1.Text;
  160. textBox1.Text = "";
  161. }
  162. }
  163.  
  164. private void button13_Click(object sender, EventArgs e)
  165. {
  166. if (textBox1.Text == "")
  167. {
  168. return;
  169. }
  170. else
  171. {
  172. multiply = true;
  173. textBox1.Tag = textBox1.Text;
  174. textBox1.Text = "";
  175. }
  176. }
  177.  
  178. private void button17_Click(object sender, EventArgs e)
  179. {
  180. if (textBox1.Text == "")
  181. {
  182. return;
  183. }
  184. else
  185. {
  186. divide = true;
  187. textBox1.Tag = textBox1.Text;
  188. textBox1.Text = "";
  189. }
  190. }
  191.  
  192. private void button11_Click(object sender, EventArgs e)
  193. {
  194. plus = minus = multiply = divide = equal = false;
  195. textBox1.Text = "";
  196. textBox1.Tag = "";
  197. }
  198. }
  199. }
Add Comment
Please, Sign In to add comment