Advertisement
Guest User

Bobo

a guest
Oct 23rd, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.53 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. public Form1()
  16. {
  17. InitializeComponent();
  18. }
  19.  
  20. private void textBox3_TextChanged(object sender, EventArgs e)
  21. {
  22.  
  23. }
  24.  
  25. private void button1_Click(object sender, EventArgs e)
  26. {
  27. int a = Convert.ToInt32(textBox1.Text);
  28. int b = Convert.ToInt32(textBox2.Text);
  29. textBox3.Text = Convert.ToString(a + b);
  30. label2.Text = "+";
  31. }
  32.  
  33. private void button2_Click(object sender, EventArgs e)
  34. {
  35. int a = Convert.ToInt32(textBox1.Text);
  36. int b = Convert.ToInt32(textBox2.Text);
  37. textBox3.Text = Convert.ToString(a - b);
  38. label2.Text = "-";
  39. }
  40.  
  41. private void button3_Click(object sender, EventArgs e)
  42. {
  43. decimal a = Convert.ToDecimal(textBox1.Text);
  44. decimal b = Convert.ToDecimal(textBox2.Text);
  45. textBox3.Text = Convert.ToString(a * b);
  46. label2.Text = "*";
  47. }
  48.  
  49. private void button4_Click(object sender, EventArgs e)
  50. {
  51. decimal a = Convert.ToDecimal(textBox1.Text);
  52. decimal b = Convert.ToDecimal(textBox2.Text);
  53. textBox3.Text = Convert.ToString(a / b);
  54. label2.Text = "/";
  55. }
  56.  
  57. private void button5_Click(object sender, EventArgs e)
  58. {
  59. textBox1.Clear();
  60. textBox2.Clear();
  61. textBox3.Clear();
  62. }
  63.  
  64. private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
  65. {
  66. char a = e.KeyChar;
  67.  
  68. if (!Char.IsDigit(a) && a != 8 && a != 42)
  69. {
  70. e.Handled = true;
  71. }
  72. }
  73.  
  74. private void textBox2_KeyPress(object sender, KeyPressEventArgs e)
  75. {
  76. char a = e.KeyChar;
  77.  
  78. if (!Char.IsDigit(a) && a != 8 && a != 42)
  79. {
  80. e.Handled = true;
  81. }
  82. }
  83.  
  84. private void textBox3_KeyPress(object sender, KeyPressEventArgs e)
  85. {
  86. char a = e.KeyChar;
  87.  
  88. if (!Char.IsDigit(a) && a != 8 && a != 42)
  89. {
  90. e.Handled = true;
  91. }
  92. }
  93. }
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement