Advertisement
Guest User

V-T-S Rechner 2.0

a guest
Oct 24th, 2014
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.45 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 Fenster : Form
  14.     {
  15.         public Fenster()
  16.         {
  17.             InitializeComponent();
  18.         }
  19.  
  20.         private void button1_Click(object sender, EventArgs e)
  21.         {
  22.  
  23.             if (vBox.Text == "")
  24.             {
  25.                 double s = Convert.ToDouble(sBox.Text);
  26.                 double t = Convert.ToDouble(tBox.Text);
  27.                 double ergebnis = 0;
  28.                 ergebnis = s / t;
  29.                 vBox.Text = Convert.ToString(ergebnis);
  30.             }
  31.  
  32.             else if (sBox.Text == "")
  33.             {
  34.                 double v = Convert.ToDouble(vBox.Text);
  35.                 double t = Convert.ToDouble(tBox.Text);
  36.                 double ergebnis = 0;
  37.                 ergebnis = v * t;
  38.                 sBox.Text = Convert.ToString(ergebnis);
  39.             }
  40.             else if (tBox.Text == "")
  41.             {
  42.                 double v = Convert.ToDouble(vBox.Text);
  43.                 double s = Convert.ToDouble(sBox.Text);
  44.                 double ergebnis = 0;
  45.                 ergebnis = s / v;
  46.                 tBox.Text = Convert.ToString(ergebnis);
  47.             }
  48.             else
  49.             {
  50.                 MessageBox.Show("Geben sie mindestens 2 Werte ein", "Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
  51.             }
  52.  
  53.         }
  54.  
  55.  
  56.  
  57.  
  58.  
  59.         private void vBox_Enter(object sender, EventArgs e)
  60.         {
  61.             if (vBox.Text != "" && sBox.Text != "" && tBox.Text != "")
  62.             {
  63.                 vBox.Text = "";
  64.                 sBox.Text = "";
  65.                 tBox.Text = "";
  66.             }
  67.         }
  68.  
  69.         private void sBox_Enter(object sender, EventArgs e)
  70.         {
  71.             if (vBox.Text != "" && sBox.Text != "" && tBox.Text != "")
  72.             {
  73.                 vBox.Text = "";
  74.                 sBox.Text = "";
  75.                 tBox.Text = "";
  76.             }
  77.         }
  78.  
  79.         private void tBox_Enter(object sender, EventArgs e)
  80.         {
  81.             if (vBox.Text != "" && sBox.Text != "" && tBox.Text != "")
  82.             {
  83.                 vBox.Text = "";
  84.                 sBox.Text = "";
  85.                 tBox.Text = "";
  86.             }
  87.         }
  88.  
  89.  
  90.  
  91.     }
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement