You are on page 1of 5

http://www.chodirin.or.

id

1. Program Perulangan Do While Design Do- While Toolbox/Properties Form Label TextBox ListBox Button Button Name Form1 Label1 txtAngka lstHasil rbtProses rbtKeluar Text Do While Angka

Proses Keluar

Kode Program
Public Class Form1 Private Sub rbtProses_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rbtProses.Click Dim angka As Integer Do While angka < txtAngka.Text angka = angka + 1 lstHasil.Items.Add("No. " & angka) Loop

End Sub Private Sub rbtKeluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rbtKeluar.Click Me.Close() End Sub End Class

Screenshoot Hasil:

2. Program Do While 2 Design: Toolbox/Properties Form Label TextBox ListBox Button Button Name Form1 Label1 txtAngka lstHasil rbtProses rbtKeluar Text Do While Angka

Proses Keluar

Kode Program:
Public Class Form1 Private Sub rbtProses_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rbtProses.Click Dim i As Integer i = txtAngka.Text Do While i >= 1 lstHasil.Items.Add("No. " & i) i = i - 1 Loop End Sub

Private Sub rbtKeluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rbtKeluar.Click Me.Close() End Sub End Class

Screenshoot:

3. Program Percabangan If Then Else Design Bonus Gaji Toolbox/Properties Form Label Label TextBox TextBox Button Button Button Name Form1 Label1 Label2 txtNama txtJumlah btnHitungBonus btnHapus btnKeluar Text Bonus Gaji Nama Jumlah Penjualan

Hitung Bonus Hapus Keluar

Kode Program
Public Class Form1 Inherits System.Windows.Forms.Form Private Sub btnHitungBonus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnHitungBonus.Click Dim data As New Karyawan Dim tulis As String

Try data.nama = Me.txtNama.Text data.jual = Decimal.Parse(Me.txtJumlah.Text) If data.jual >= 50000000 Then data.bonus = data.jual * 0.05 If data.jual >= 75000000 Then data.bonus = data.jual * 0.1 If data.jual >= 100000000 Then data.bonus = data.jual * 0.15 End If End If End If tulis = "Nama Penjual :" + data.nama + Chr(13) + _ "Jumlah Penjualan : " + CStr(data.jual) + Chr(13) + Chr(13) + _ "Jumlah Bonus :" + CStr(data.bonus) MessageBox.Show(tulis, "Hasil", MessageBoxButtons.OK) Catch ex As Exception MessageBox.Show(ex.Message, "Tak terbatas", MessageBoxButtons.OK, MessageBoxIcon.Information) End Try End Sub Private Sub btnKeluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnKeluar.Click Me.Close() End Sub Private Sub btnHapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnHapus.Click txtNama.Clear() txtJumlah.Clear() End Sub End Class

Kode program class Karyawan.vb


Public Class Karyawan Public nama As String Public jual As Double Public bonus As Double End Class

Ada Screenshoot Hasil:

You might also like