Advertisement
AlphaPenguino

Window Form C#

Nov 5th, 2024
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.32 KB | Source Code | 0 0
  1. using static System.Runtime.InteropServices.JavaScript.JSType;
  2.  
  3. namespace Pacis_WinFormsApp1
  4. {
  5.  
  6.     public partial class Form1 : Form
  7.     {
  8.  
  9.  
  10.         public Form1()
  11.         {
  12.  
  13.             InitializeComponent();
  14.  
  15.         }
  16.  
  17.         private void textBox1_TextChanged(object sender, EventArgs e)
  18.         {
  19.  
  20.  
  21.  
  22.         }
  23.  
  24.         private void textBox2_TextChanged(object sender, EventArgs e)
  25.         {
  26.  
  27.  
  28.         }
  29.         private void label1_Click(object sender, EventArgs e)
  30.         {
  31.  
  32.         }
  33.  
  34.         private void label2_Click(object sender, EventArgs e)
  35.         {
  36.  
  37.         }
  38.  
  39.         private void button1_Click(object sender, EventArgs e)
  40.         {
  41.             string n1 = textBox1.Text;
  42.             string n2 = textBox2.Text;
  43.  
  44.             if ((!double.TryParse(n1, out double d)) || (!double.TryParse(n2, out double d1)))
  45.             {
  46.                 MessageBox.Show("No letters please!");
  47.                 textBox1.Clear();
  48.                 textBox2.Clear();
  49.             }
  50.             else
  51.             {
  52.                 double d3 = d + d1;
  53.                 textBox3.Text = d3.ToString();
  54.             }
  55.  
  56.         }
  57.  
  58.         private void label3_Click(object sender, EventArgs e)
  59.         {
  60.  
  61.         }
  62.  
  63.         private void textBox3_TextChanged(object sender, EventArgs e)
  64.         {
  65.  
  66.         }
  67.  
  68.         private void button5_Click(object sender, EventArgs e)
  69.         {
  70.             textBox1.Clear();
  71.             textBox2.Clear();
  72.             textBox3.Clear();
  73.         }
  74.  
  75.         private void button2_Click(object sender, EventArgs e)
  76.         {
  77.             string n1 = textBox1.Text;
  78.             string n2 = textBox2.Text;
  79.  
  80.             if ((!double.TryParse(n1, out double d)) || (!double.TryParse(n2, out double d1)))
  81.             {
  82.                 MessageBox.Show("No letters please!");
  83.                 textBox1.Clear();
  84.                 textBox2.Clear();
  85.             }
  86.             else
  87.             {
  88.                 double d3 = d - d1;
  89.                 textBox3.Text = d3.ToString();
  90.             }
  91.         }
  92.  
  93.         private void button3_Click(object sender, EventArgs e)
  94.         {
  95.             string n1 = textBox1.Text;
  96.             string n2 = textBox2.Text;
  97.  
  98.             if ((!double.TryParse(n1, out double d)) || (!double.TryParse(n2, out double d1)))
  99.             {
  100.                 MessageBox.Show("ERROR, INVALID INPUT!");
  101.                 textBox1.Clear();
  102.                 textBox2.Clear();
  103.             }
  104.             else
  105.             {
  106.                 double d3 = d * d1;
  107.                 textBox3.Text = d3.ToString();
  108.             }
  109.         }
  110.  
  111.         private void button4_Click(object sender, EventArgs e)
  112.         {
  113.             string n1 = textBox1.Text;
  114.             string n2 = textBox2.Text;
  115.  
  116.             if ((!double.TryParse(n1, out double d)) || (!double.TryParse(n2, out double d1)))
  117.             {
  118.                 MessageBox.Show("No letters please!");
  119.                 textBox1.Clear();
  120.                 textBox2.Clear();
  121.             }
  122.             else
  123.             {
  124.                 if (d1 == 0)
  125.                 {
  126.                     textBox3.Text = "MATH_ERROR";
  127.                 }
  128.                 else {
  129.                     double d3 = d / d1;
  130.                     textBox3.Text = d3.ToString();
  131.                 }
  132.                
  133.             }
  134.         }
  135.     }
  136. }
  137.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement