Form Design ListView :
Penulisan Script :
Public Class Form1
Sub buattable( )
LV.Columns.Add("NIK", 40, HorizontalAlignment.Center)
LV.Columns.Add("Nama", 100, HorizontalAlignment.Center)
LV.Columns.Add("Jabatan", 80, HorizontalAlignment.Center)
LV.Columns.Add("Gaji", 80, HorizontalAlignment.Center)
LV.Columns.Add("Status", 70, HorizontalAlignment.Center)
LV.Columns.Add("Tunjangan Istri", 100, HorizontalAlignment.Center)
LV.Columns.Add("Jumlah Anak", 90, HorizontalAlignment.Center)
LV.Columns.Add("Tunjangan Anak", 100, HorizontalAlignment.Center)
LV.Columns.Add("Jam Lembur", 100, HorizontalAlignment.Center)
LV.Columns.Add("Honor Lembur", 100, HorizontalAlignment.Center)
LV.Columns.Add("Pajak", 75, HorizontalAlignment.Center)
LV.Columns.Add("Total", 80, HorizontalAlignment.Center)
LV.View = View.Details
LV.GridLines = True
End Sub
Sub isitable( )
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(tunjanganistri.Text)
Lst.SubItems.Add(jumlahanak.Text)
Lst.SubItems.Add(tunjangananak.Text)
Lst.SubItems.Add(jamlembur.Text)
Lst.SubItems.Add(honorlembur.Text)
Lst.SubItems.Add(pajak.Text)
Lst.SubItems.Add(total.Text)
LV.Items.Add(Lst)
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
nik.Items.Add("001")
nik.Items.Add("002")
nik.Items.Add("003")
jabatan.Items.Add("Mandor")
jabatan.Items.Add("Kepala Bagian")
jabatan.Items.Add("Staff")
status.Items.Add("Menikah")
status.Items.Add("Tidak Menikah")
For i = 1 To 4
jumlahanak.Items.Add(i)
Next i
For i = 1 To 10
jamlembur.Items.Add(i)
Next i
Call buattable()
End Sub
Private Sub nik_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles nik.SelectedIndexChanged
Select nik.Text
Case "001" : nama.Text = "Tukimin"
Case "002" : nama.Text = "Marito"
Case "003" : nama.Text = "Sutiman"
End Select
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
pajak.Text = 0.015 * gaji.Text
Case "Kepala Bagian" : gaji.Text = 2500000
pajak.Text = 0.015 * gaji.Text
Case "staff" : gaji.Text = 1250000
pajak.Text = 0.015 * gaji.Text
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") : tunjanganistri.Text = 0.09 * gaji.Text
Case ("Tidak Menikah") : tunjanganistri.Text = 0
End Select
End Sub
Private Sub jumlahanak_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles jumlahanak.SelectedIndexChanged
If jumlahanak.Text >= 2 And status.Text = "Menikah" Then
tunjangananak.Text = 0.07 * gaji.Text
ElseIf jumlahanak.Text = 1 And status.Text = "Menikah" Then
tunjangananak.Text = 0.03 * gaji.Text
Else
tunjangananak.Text = 0
End If
End Sub
Private Sub btnproses_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnproses.Click
If jabatan.Text = "Mandor" Then
honorlembur.Text = "7500"
ElseIf jabatan.Text = "Kepala Bagian" Then
honorlembur.Text = "10000"
ElseIf jabatan.Text = "Staff" Then
honorlembur.Text = "5000"
Else
honorlembur.Text = 0
End If
total.Text = Val(honorlembur.Text * jamlembur.Text) + Val(gaji.Text) + Val(tunjanganistri.Text) + Val(tunjangananak.Text) + Val(pajak.Text)
End Sub
Private Sub btnkeluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnkeluar.Click
End
End Sub
Private Sub btnsimpanlv_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsimpanlv.Click
isitable( )
nik.Text = ""
nama.Text = ""
jabatan.Text = ""
gaji.Text = ""
status.Text = ""
tunjanganistri.Text = ""
jumlahanak.Text = ""
tunjangananak.Text = ""
jamlembur.Text = ""
honorlembur.Text = ""
pajak.Text = ""
total.Text = ""
End Sub
Private Sub btnhapussemuadatalv_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnhapussemuadatalv.Click
LV.Items.Clear( )
End Sub
Private Sub btnhapusdatalvterpilih_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnhapusdatalvterpilih.Click
LV.Items.Remove(LV.SelectedItems(0))
End Sub
End Class