0% found this document useful (0 votes)
49 views

Using Using Using Using Using Using Using Using Using Namespace Public Partial Class Public

The document contains code for two Windows Forms applications. The first application populates a combo box with the results of multiplying integers from 1 to a given number. The second application sorts user-entered integer values into even and odd arrays, and displays them in separate combo boxes. It checks the array size does not exceed the specified capacity before adding new values.

Uploaded by

hermainaputri
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views

Using Using Using Using Using Using Using Using Using Namespace Public Partial Class Public

The document contains code for two Windows Forms applications. The first application populates a combo box with the results of multiplying integers from 1 to a given number. The second application sorts user-entered integer values into even and odd arrays, and displays them in separate combo boxes. It checks the array size does not exceed the specified capacity before adding new values.

Uploaded by

hermainaputri
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 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
}
}
}
}

You might also like