AalborgHTX

IF betingelse

Dec 20th, 2018
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.91 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 Hvadharduskrevet
  12. {
  13.     public partial class Form1 : Form
  14.     {
  15.         public Form1()
  16.         {
  17.             InitializeComponent();
  18.         }
  19.  
  20.         private void btnKnap_Click(object sender, EventArgs e)
  21.         {
  22.             string temp = txtInput.Text;
  23.             int tal = int.Parse(temp);
  24.  
  25.             if (tal == 3)
  26.             {
  27.                 lstOutput.Items.Add("Du har trykket på 3");
  28.             }
  29.  
  30.             else if (tal ==4)
  31.             {
  32.                 lstOutput.Items.Add("Du har trykket på 4");
  33.             }
  34.  
  35.             else
  36.             {
  37.                 lstOutput.Items.Add("Du har ikke skrevet 3 eller 4");
  38.             }
  39.         }
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment