Program Visual Basic Pemakaian Listview Penggajian Karyawan
Pada program berikut ini akan diulas kembali untuk kasus yang hampir sama yaitu penggajian karyawan.
Silahkan design form Program Visual Basic Pemakaian Listview Penggajian Karyawan berikut ini .
Untuk perintah ikutin instruksi berikut .
Paling atas Code Program ketikkan perintah berikut ini :
Dim lst As ListItem
Double click Combo NIK rubah event menjadi Click
Private Sub NIK_Click()
Select Case NIK.Text
Case "001": Nama.Text = "Oncom"
Case "002": Nama.Text = "Udin"
Case "003": Nama.Text = "Ujang"
End Select
End Sub
Double click Combo Status rubah event menjadi Click
Private Sub Status_Click()
Select Case Status.Text
Case "Menikah": TunjKeluarga.Text = 0.15 * Gaji.Text
Case "Tidak Menikah": TunjKeluarga.Text = 0
End Select
Total.Text = Val(Gaji.Text) + Val(TunjKeluarga.Text) - Val(Pajak.Text)
End Sub
Double Click Form
Private Sub Form_Load()
NIK.AddItem "001"
NIK.AddItem "002"
NIK.AddItem "003"
Jabatan.AddItem "Mandor"
Jabatan.AddItem "Kepala Bagian"
Jabatan.AddItem "Staf"
Status.AddItem "Menikah"
Status.AddItem "Tidak Menikah"
Call cmdBaru_Click
Listview1.ColumnHeaders.Add , , "NIK", 1000
Listview1.ColumnHeaders.Add , , "Nama", 3000
Listview1.ColumnHeaders.Add , , "Jabatan", 1500
Listview1.ColumnHeaders.Add , , "Gaji", 1000
Listview1.ColumnHeaders.Add , , "Status", 1000
Listview1.ColumnHeaders.Add , , "Tunj. Keluarga", 1500
Listview1.ColumnHeaders.Add , , "Pajak", 1000
Listview1.ColumnHeaders.Add , , "Total Gaji", 1500
Listview1.GridLines = True
Listview1.FullRowSelect = True
Listview1.View = lvwReport
End Sub
Double Click Combo Jabatan rubah event menjadi Click
Private Sub Jabatan_Click()
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
Double Click Command Baru
Private Sub cmdBaru_Click()
NIK.Text = ""
Nama.Text = ""
Status.Text = ""
Jabatan.Text = ""
Pajak.Text = ""
Total.Text = ""
Gaji.Text = ""
TunjKeluarga.Text = ""
End Sub
Double Click Command Proses
Private Sub CmdProses_Click()
Set lst = Listview1.ListItems.Add(, , NIK.Text)
lst.SubItems(1) = Nama.Text
lst.SubItems(2) = Jabatan.Text
lst.SubItems(3) = Gaji.Text
lst.SubItems(4) = Status.Text
lst.SubItems(5) = TunjKeluarga.Text
lst.SubItems(6) = Pajak.Text
lst.SubItems(7) = Total.Text
Call cmdBaru_Click
End Sub
Double Click Command Keluar
Private Sub CmdKeluar_Click()
Unload Me
End Sub
Sehingga keseluruhan program dapat terlihat seperti berikut ini :
Dim lst As ListItem
Private Sub cmdBaru_Click()
NIK.Text = ""
Nama.Text = ""
Status.Text = ""
Jabatan.Text = ""
Pajak.Text = ""
Total.Text = ""
Gaji.Text = ""
TunjKeluarga.Text = ""
End Sub
Private Sub CmdKeluar_Click()
Unload Me
End Sub
Private Sub CmdProses_Click()
Set lst = Listview1.ListItems.Add(, , NIK.Text)
lst.SubItems(1) = Nama.Text
lst.SubItems(2) = Jabatan.Text
lst.SubItems(3) = Gaji.Text
lst.SubItems(4) = Status.Text
lst.SubItems(5) = TunjKeluarga.Text
lst.SubItems(6) = Pajak.Text
lst.SubItems(7) = Total.Text
Call cmdBaru_Click
End Sub
Private Sub Form_Load()
NIK.AddItem "001"
NIK.AddItem "002"
NIK.AddItem "003"
Jabatan.AddItem "Mandor"
Jabatan.AddItem "Kepala Bagian"
Jabatan.AddItem "Staf"
Status.AddItem "Menikah"
Status.AddItem "Tidak Menikah"
Call cmdBaru_Click
Listview1.ColumnHeaders.Add , , "NIK", 1000
Listview1.ColumnHeaders.Add , , "Nama", 3000
Listview1.ColumnHeaders.Add , , "Jabatan", 1500
Listview1.ColumnHeaders.Add , , "Gaji", 1000
Listview1.ColumnHeaders.Add , , "Status", 1000
Listview1.ColumnHeaders.Add , , "Tunj. Keluarga", 1500
Listview1.ColumnHeaders.Add , , "Pajak", 1000
Listview1.ColumnHeaders.Add , , "Total Gaji", 1500
Listview1.GridLines = True
Listview1.FullRowSelect = True
Listview1.View = lvwReport
End Sub
Private Sub Jabatan_Click()
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_Click()
Select Case NIK.Text
Case "001": Nama.Text = "Oncom"
Case "002": Nama.Text = "Udin"
Case "003": Nama.Text = "Ujang"
End Select
End Sub
Private Sub Status_Click()
Select Case Status.Text
Case "Menikah": TunjKeluarga.Text = 0.15 * Gaji.Text
Case "Tidak Menikah": TunjKeluarga.Text = 0
End Select
Total.Text = Val(Gaji.Text) + Val(TunjKeluarga.Text) - Val(Pajak.Text)
End Sub
Untuk menjalankan program silahkan Tekan F5. Sehingga hasil program seperti berikut ini.
Tidak ada komentar:
Posting Komentar