Advertisement
Guest User

Untitled

a guest
Apr 16th, 2014
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.35 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.Threading.Tasks;
  9. using System.Windows.Forms;
  10.  
  11. namespace WindowsFormsApplication1
  12. {
  13. public partial class Form1 : Form
  14. {
  15.  
  16. enum oper
  17. {
  18. plus,
  19. minus,
  20. mnozenie,
  21. dziel
  22.  
  23.  
  24. }
  25.  
  26.  
  27. public Form1()
  28. {
  29. InitializeComponent();
  30. }
  31. float pamiec;
  32. oper operacja;
  33.  
  34. private void _1_Click(object sender, EventArgs e)
  35. {
  36. textBox1.Text += "1";
  37. //float.Parse("67");
  38. }
  39.  
  40. private void _2_Click(object sender, EventArgs e)
  41. {
  42. textBox1.Text += "2";
  43. }
  44.  
  45. private void _3_Click(object sender, EventArgs e)
  46. {
  47. textBox1.Text += "3";
  48. }
  49.  
  50. private void _4_Click(object sender, EventArgs e)
  51. {
  52. textBox1.Text += "4";
  53. }
  54.  
  55. private void _5_Click(object sender, EventArgs e)
  56. {
  57. textBox1.Text += "5";
  58. }
  59.  
  60. private void _6_Click(object sender, EventArgs e)
  61. {
  62. textBox1.Text += "6";
  63. }
  64.  
  65. private void _7_Click(object sender, EventArgs e)
  66. {
  67. textBox1.Text += "7";
  68. }
  69.  
  70. private void _8_Click(object sender, EventArgs e)
  71. {
  72. textBox1.Text += "8";
  73. }
  74.  
  75. private void _9_Click(object sender, EventArgs e)
  76. {
  77. textBox1.Text += "9";
  78. }
  79.  
  80. private void _0_Click(object sender, EventArgs e)
  81. {
  82. textBox1.Text += "0";
  83. }
  84.  
  85. private void _plus_Click(object sender, EventArgs e)
  86. {
  87. pamiec = float.Parse(textBox1.Text);
  88. operacja = oper.plus;
  89. textBox1.Text="";
  90. }
  91.  
  92. private void _suma_Click(object sender, EventArgs e)
  93. {
  94. float wynik = 0;
  95. float arg2=float.Parse(textBox1.Text);
  96. switch(operacja){
  97. case oper.plus:
  98. wynik= pamiec + arg2;
  99. break;
  100. case oper.minus:
  101. wynik = pamiec - arg2;
  102. break;
  103. case oper.dziel:
  104. wynik = pamiec / arg2;
  105. break;
  106. case oper.mnozenie:
  107. wynik = pamiec * arg2;
  108. break;
  109. }
  110. textBox1.Text=wynik.ToString();
  111. }
  112.  
  113. private void _minus_Click(object sender, EventArgs e)
  114. {
  115. pamiec = float.Parse(textBox1.Text);
  116. operacja = oper.minus;
  117. textBox1.Text = "";
  118. }
  119.  
  120. private void _mnozenie_Click(object sender, EventArgs e)
  121. {
  122. pamiec = float.Parse(textBox1.Text);
  123. operacja = oper.mnozenie;
  124. textBox1.Text = "";
  125. }
  126.  
  127. private void _dziel_Click(object sender, EventArgs e)
  128. {
  129. pamiec = float.Parse(textBox1.Text);
  130. operacja = oper.dziel;
  131. textBox1.Text = "";
  132. }
  133.  
  134. private void przecinek_Click(object sender, EventArgs e)
  135. {
  136. textBox1.Text += ",";
  137. }
  138. }
  139. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement