Guest User

Untitled

a guest
Jan 23rd, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.85 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 Calculator : Form
  13. {
  14. public Calculator()
  15. {
  16. InitializeComponent();
  17. }
  18. private bool plusbool = false;
  19. private bool minbool =false;
  20. private bool keerbool =false;
  21. private bool deelbool =false;
  22. private bool Nummer0bool = false;
  23. private bool ButtonDotbool = false;
  24. double invoer1double;
  25. double invoer2double;
  26. double antwoorddouble;
  27.  
  28. private void Nummer1_Click(object sender, EventArgs e)
  29. {
  30. invoer1.Text = invoer1.Text + 1;
  31. antwoord.Text = "";
  32. }
  33.  
  34. private void Nummer2_Click(object sender, EventArgs e)
  35. {
  36. invoer1.Text = invoer1.Text + 2;
  37. antwoord.Text = "";
  38. }
  39.  
  40. private void Nummer3_Click(object sender, EventArgs e)
  41. {
  42. invoer1.Text = invoer1.Text + 3;
  43. antwoord.Text = "";
  44. }
  45.  
  46. private void Nummer4_Click(object sender, EventArgs e)
  47. {
  48. invoer1.Text = invoer1.Text + 4;
  49. antwoord.Text = "";
  50. }
  51.  
  52. private void Nummer5_Click(object sender, EventArgs e)
  53. {
  54. invoer1.Text = invoer1.Text + 5;
  55. antwoord.Text = "";
  56. }
  57.  
  58. private void Nummer6_Click(object sender, EventArgs e)
  59. {
  60. invoer1.Text = invoer1.Text + 6;
  61. antwoord.Text = "";
  62. }
  63.  
  64. private void Nummer7_Click(object sender, EventArgs e)
  65. {
  66. invoer1.Text = invoer1.Text + 7;
  67. antwoord.Text = "";
  68. }
  69.  
  70. private void Nummer8_Click(object sender, EventArgs e)
  71. {
  72. invoer1.Text = invoer1.Text + 8;
  73. antwoord.Text = "";
  74. }
  75.  
  76. private void Nummer9_Click(object sender, EventArgs e)
  77. {
  78. invoer1.Text = invoer1.Text + 9;
  79. antwoord.Text = "";
  80. }
  81.  
  82. private void Nummer0_Click(object sender, EventArgs e)
  83. {
  84. if (invoer1.Text == "") { }
  85. else
  86. {
  87. invoer1.Text = invoer1.Text + 0;
  88. antwoord.Text = "";
  89. }
  90. }
  91.  
  92. private void buttonDot_Click(object sender, EventArgs e)
  93. {
  94. if (Nummer0bool == true) { }
  95. if (ButtonDotbool == true) { }
  96. else
  97. {
  98. if (Nummer0bool == true)
  99. {
  100. if (ButtonDotbool == true) { }
  101. else
  102. {
  103. invoer1.Text = invoer1.Text + ".";
  104. antwoord.Text = "";
  105. ButtonDotbool = true;
  106. }
  107. }
  108. else
  109. {
  110. if (ButtonDotbool == true) { }
  111. else
  112. {
  113. invoer1.Text = invoer1.Text + "0";
  114. antwoord.Text = "";
  115. ButtonDotbool = true;
  116. }
  117.  
  118. {
  119.  
  120. invoer1.Text = invoer1.Text + ".";
  121. antwoord.Text = "";
  122. }
  123. }
  124. }
  125. }
  126.  
  127.  
  128.  
  129.  
  130.  
  131. private void buttonPlus_Click(object sender, EventArgs e)
  132. {
  133. invoer2.Text = invoer1.Text;
  134. invoer2double = double.Parse(invoer2.Text);
  135. invoer1.Text = "";
  136. plusbool = true;
  137. minbool = false;
  138. keerbool = false;
  139. deelbool = false;
  140. }
  141.  
  142. private void buttonMinus_Click(object sender, EventArgs e)
  143. {
  144. invoer2.Text = invoer1.Text;
  145. invoer2double = double.Parse(invoer2.Text);
  146. invoer1.Text = "";
  147. plusbool = false;
  148. minbool = true;
  149. keerbool = false;
  150. deelbool = false;
  151. }
  152.  
  153. private void buttonTimes_Click(object sender, EventArgs e)
  154. {
  155. invoer2.Text = invoer1.Text;
  156. invoer2double = double.Parse(invoer2.Text);
  157. invoer1.Text = "";
  158. plusbool = false;
  159. minbool = false;
  160. keerbool = true;
  161. deelbool = false;
  162. }
  163.  
  164. private void buttonDivide_Click(object sender, EventArgs e)
  165. {
  166. invoer2.Text = invoer1.Text;
  167. invoer2double = double.Parse(invoer2.Text);
  168. invoer1.Text = "";
  169. plusbool = false;
  170. minbool = false;
  171. keerbool = false;
  172. deelbool = true;
  173. }
  174.  
  175. private void buttonResult_Click(object sender, EventArgs e)
  176. {
  177. invoer1double = double.Parse(invoer1.Text);
  178. if (plusbool == true) antwoorddouble = invoer1double + invoer2double;
  179. if (minbool == true) antwoorddouble = invoer1double - invoer2double;
  180. if (keerbool == true) antwoorddouble = invoer1double * invoer2double;
  181. if (deelbool == true) antwoorddouble = invoer1double / invoer2double;
  182. antwoord.Text = antwoorddouble.ToString();
  183. invoer1.Text = "";
  184. invoer2.Text = "";
  185. plusbool = false;
  186. minbool = false;
  187. keerbool = false;
  188. deelbool = false;
  189. }
  190.  
  191. private void buttonClearAll_Click(object sender, EventArgs e)
  192. {
  193.  
  194. }
  195.  
  196. private void Invoer1_TextChanged(object sender, EventArgs e)
  197. {
  198.  
  199. }
  200.  
  201. private void Invoer2_TextChanged(object sender, EventArgs e)
  202. {
  203.  
  204. }
  205.  
  206. private void Antwoord_TextChanged(object sender, EventArgs e)
  207. {
  208.  
  209. }
  210.  
  211.  
  212. }
  213. }
Add Comment
Please, Sign In to add comment