You are on page 1of 4

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 Tugas_khawa
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)


{
comboBox1.Items.Clear();
int z;
int batas = Convert.ToInt32(textBox1.Text);

for (int i = 1; i <= batas; i++)


{
z = i * (i + 1);

comboBox1.Items.Add(z);
}
comboBox1.DroppedDown = true;
}
}
}
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 Tugas_khawa
{
public partial class Form3 : Form
{
int a = 0, x = 0;
int[] angka;
public Form3()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)


{
a = Convert.ToInt32(textBox1.Text);
angka = new int[a];
// ini untuk mengisi banyaknya data array
this.ActiveControl = textBox2;
}

private void button3_Click(object sender, EventArgs e)


{
for (int i = 1; i <= angka.Length - 1; i++)
{
for (int j = 0; j < angka.Length - 1; j++)
{
if (angka[j] < angka[j + 1])
{
int temp = angka[j + 1];
angka[j + 1] = angka[j];
angka[j] = temp;
}
}
}

for (int i = 0; i <= angka.Length - 1; i++)


{
if (angka[i] % 2 == 0)

comboBox4.Items.Add(angka[i]);
else

{
comboBox3.Items.Add(angka[i]);
}
}
}

private void button2_Click(object sender, EventArgs e)


{
if (x >= a)
{
MessageBox.Show("Kapasitas Penyimpanan" + "Data Anda Tidak Cukup",
"Warning", MessageBoxButtons.OK);
}
else
{
angka[x] = Convert.ToInt32(textBox2.Text); //masukkan data ke array
comboBox2.Items.Add(angka[x]); //Memasukkan data ke comboBox 1 per 1
x++; // penambahan indeks
textBox2.Text = ""; // Pengosongan TextBox
this.ActiveControl = textBox2; // memindahkan kursor ke textbox
}
}
}
}