Advertisement
Guest User

Untitled

a guest
Mar 29th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.68 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 WindowsFormsApp5
  12. {
  13.     public partial class Form1 : Form
  14.     {
  15.         public Form1()
  16.         {
  17.             InitializeComponent();
  18.             label1.Text = "Plox";
  19.         }
  20.  
  21.         private void textBox1_TextChanged(object sender, EventArgs e)
  22.         {
  23.             int plox;
  24.             int plox2;
  25.             int max;
  26.             listBox1.Items.Clear();
  27.             if (textBox1.Text != "" && textBox2.Text != "")
  28.             {
  29.                 try
  30.                 {
  31.                     plox = Convert.ToInt32(textBox1.Text);
  32.                     plox2 = Convert.ToInt32(textBox2.Text);
  33.                     if (plox > plox2)
  34.                     {
  35.                         max = plox;
  36.                     }
  37.                     else
  38.                     {
  39.                         max = plox2;
  40.                     }
  41.                     for (int i = 1; i <= max; i++)
  42.                     {
  43.                         if (plox % i == 0 && plox2 % i == 0)
  44.                         {
  45.                             listBox1.Items.Add(i);
  46.                             label1.Text = Convert.ToString(i);
  47.                         }
  48.                     }
  49.  
  50.                 }
  51.                 catch
  52.                 {
  53.                     label1.Text = "Bitte Gültige werte eingeben";
  54.                 }
  55.             }
  56.             else
  57.             {
  58.                 label1.Text = "Bitte Gültige werte eingeben";
  59.             }
  60.            
  61.         }
  62.     }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement