Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace WindowsFormsApp5
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- label1.Text = "Plox";
- }
- private void textBox1_TextChanged(object sender, EventArgs e)
- {
- int plox;
- int plox2;
- int max;
- listBox1.Items.Clear();
- if (textBox1.Text != "" && textBox2.Text != "")
- {
- try
- {
- plox = Convert.ToInt32(textBox1.Text);
- plox2 = Convert.ToInt32(textBox2.Text);
- if (plox > plox2)
- {
- max = plox;
- }
- else
- {
- max = plox2;
- }
- for (int i = 1; i <= max; i++)
- {
- if (plox % i == 0 && plox2 % i == 0)
- {
- listBox1.Items.Add(i);
- label1.Text = Convert.ToString(i);
- }
- }
- }
- catch
- {
- label1.Text = "Bitte Gültige werte eingeben";
- }
- }
- else
- {
- label1.Text = "Bitte Gültige werte eingeben";
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement