Anda di halaman 1dari 6

Quis Pertemuan 7 - Pemrograman Visual II

LOOPING

Nama : Halennopejumsisati
NPM : 19403165
Kelas : IRM -L41/19

1. Buka aplikasi Microsoft visual studio


2. Klik File > New Project

3. Pilih Windows Form Application > Beri Nama Project tersebut kemudian klik OK
4. Berikut nama objek dan property yang digunakan

No Objek Properti Nilai Properti


1 Solution Name Latihan 5
Explorer Name FormLatihan5
Form1 StartPosition CenterScreen
2 GroupBox1 Pengulangan For, While,
Text Do
Dock Top
Label1 Text Nilai Awal
Label2 Text Nilai Akhir
Textbox1 Name Textbox1
Textbox2 Name Textbox2
Button1 Name For - Next
Button2 Name While – End While
Button3 Name Do While – Loop
Button4 Name Clear
3 GroupBox2 Text Hasil
Dock Bottom
ListBox1 Name Listbox1

5. Setelah design dari form tersebut selesai, sekarang tinggal masuk bagian pembuatan syntax
supaya program bisa dijalankan sesuai keinginan.
a. Double klik button1 ( For - Next ), kemudian ketikkan syntax berikut
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim x, y As Integer
x = Val(TextBox1.Text)
y = Val(TextBox2.Text)
For i = x To y
ListBox1.Items.Add(i)
Next
End Sub

b. Double klik button2 ( While – EndWhile ), kemudian ketikkan syntax berikut


Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Dim x As Integer
x = Val(TextBox1.Text)
While x <= Val(TextBox2.Text)
ListBox1.Items.Add(x)
x = x + 1
End While
End Sub
c. Double klik button3 ( Do While – Loop ), kemudian ketikkan syntax berikut
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click
Dim x As Integer
x = Val(TextBox1.Text)
Do While x <= Val(TextBox2.Text)
ListBox1.Items.Add(x)
x = x + 1
Loop
End Sub

d. Double klik pada button4 ( Clear ), kemudian masukan syntax sebagai berikut :
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button4.Click
TextBox1.Clear()
TextBox2.Clear()
ListBox1.Items.Clear()
End Sub
e. Kemudian klik tombol save all lalu ganti nama file sesuai keinginan.

f. Kemudian klik start debugging untuk memulai simulasi aplikasi tersebut

6. Untuk memperindah tampilan bisa klik Properties - Backcolor - Pilih Warna -Ok

Anda mungkin juga menyukai