Pertama,buatlah desain form nya terlebih dahulu seperti di bawah ini :
Kemudian ketik listing programnya seperti di bawah ini :
Public Class
Form1
Private Sub Form1_Load(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
buatTabel()
nik.Items.Add("001")
nik.Items.Add("002")
nik.Items.Add("003")
jabatan.Items.Add("Mandor")
jabatan.Items.Add("Kepala Bagian")
jabatan.Items.Add("Staf")
status.Items.Add("Menikah")
status.Items.Add("Tidak Menikah")
End Sub
Private Sub jabatan_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As
System.EventArgs) Handles
jabatan.SelectedIndexChanged
Select Case jabatan.Text
Case
"Mandor" : gaji.Text =
1750000
Case
"Kepala Bagian" :
gaji.Text =
2500000
Case
"Staf" : gaji.Text =
1250000
End Select
pajak.Text = 0.15 * gaji.Text
End Sub
Private Sub nik_SelectedIndexChanged(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles
nik.SelectedIndexChanged
Select Case nik.Text
Case
"001" : nama.Text = "Bardan"
Case
"002" : nama.Text = "Tia"
Case
"003" : nama.Text = "Rinawati"
End Select
End Sub
Private Sub status_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As
System.EventArgs) Handles
status.SelectedIndexChanged
Select Case status.Text
Case
"Menikah" :
tjkeluarga.Text = 0.15
* gaji.Text
Case
"Tidak Menikah" :
tjkeluarga.Text
= 0
End Select
End Sub
Private Sub proses_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles proses.Click
total.Text = Val(gaji.Text) +
Val(tjkeluarga.Text) - Val(pajak.Text)
End Sub
Private Sub baru_Click_1(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles baru.Click
nik.Text = ""
nama.Text = ""
jabatan.Text = ""
gaji.Text = ""
status.Text = ""
tjkeluarga.Text = ""
pajak.Text = ""
total.Text = ""
End Sub
Private Sub keluar_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles keluar.Click
End
End Sub
Sub
buatTabel()
LV.Columns.Add("NIK",
80, HorizontalAlignment.Center)
LV.Columns.Add("NAMA",
100, HorizontalAlignment.Left)
LV.Columns.Add("JABATAN",
100, HorizontalAlignment.Left)
LV.Columns.Add("GAJI",
100, HorizontalAlignment.Left)
LV.Columns.Add("STATUS",
100, HorizontalAlignment.Left)
LV.Columns.Add("TUNJ
KELUARGA", 100, HorizontalAlignment.Left)
LV.Columns.Add("PAJAK",
100, HorizontalAlignment.Left)
LV.Columns.Add("TOTAL
GAJI", 100, HorizontalAlignment.Left)
LV.View = View.Details
LV.gridlines = True
LV.fullrowselect = True
End Sub
Sub
isitabel()
Dim Lst
As New
ListViewItem
Lst.Text = nik.Text
Lst.SubItems.Add(nama.Text)
Lst.SubItems.Add(jabatan.Text)
Lst.SubItems.Add(gaji.Text)
Lst.SubItems.Add(status.Text)
Lst.SubItems.Add(tjkeluarga.Text)
Lst.SubItems.Add(pajak.Text)
Lst.SubItems.Add(total.Text)
LV.Items.Add(Lst)
End Sub
Private Sub Button1_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles
Button1.Click
isitabel()
nik.Text = ""
nama.Text = ""
jabatan.Text = ""
gaji.Text = ""
status.Text = ""
tjkeluarga.Text = ""
pajak.Text = ""
total.Text = ""
End Sub
Private Sub Button2_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles
Button2.Click
LV.Items.Clear()
End Sub
Private Sub Button3_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles
Button3.Click
LV.Items.Remove(LV.SelectedItems(0))
End Sub
End Class
Cara menjalan klik debug atau tekan F5,
Gambar 2: Tampilan program saat dijalankan |
SELAMAT MENCOBA :)