UTS Pemrograman Visual

Soal:
Buatlah FORM UJI pada visual basic untuk menghitung gaji bersih pegawai pada gambar dibawah ini:


Dengan ketentuan sebagai berikut:
GOLONGAN:
A = Rp 1.000.ooo
B = Rp 800.000
C = Rp 600.000

NIP, NAMA, GOL (Golongan), JENKEL (Jenis Kelamin) dan STAT (Status Kawin) di input dari program dan untuk menentukan TUNJANGAN ANAK, TUNJANGAN ISTRI dan POTONGAN
jika STATUS = “K” dan JENKEL = “L”
TUNJANGAN per ANAK = Rp 70.000
TUNJANGAN ISTRI = 90.000
POTONGAN = 15.000
jika STATUS = “K” dan JENKEL = “P”
TUNJANGAN per ANAK = 50.000
TUNJANGAN ISTRI = 0
POTONGAN = 25.000
Jika STATUS= “B” dan JENKEL = “P”
TUNJANGAN per ANAK = 0TUNJANGAN ISTRI = 0
POTONGAN = 35.000
jika STATUS = “B” dan JENKEL = “L”
TUNJANGAN per ANAK = 0
TUNJANGAN ISTRI = 0
POTONGAN = 40.000
GAJI BERSIH = (GAPOK + TUNJANGAN ANAK + TUNJANGAN ISTRI) – POTONGAN


Jawaban:


Code:
Public hobi, hobi0, hobi1, hobi2, hobi3, hobi4
Public jk, st, jenkel, i, nama, nip, gol, gapok
Public tunjanganperanak, tunjanganistri, potongan

Private Sub cmdbersih_Click()

cleartext Me
List.Clear
txtnip.SetFocus

End Sub

Private Sub cmdhitung_Click()

If cmbjenkel.ListIndex = 0 Then jk = "L" Else jk = "P"
If cmbstatus.ListIndex = 0 Then st = "K" Else st = "TK"


If chkhobby(0).Value = 1 Then hobi0 = "BACA" Else hobi0 = ""
If chkhobby(1).Value = 1 Then hobi1 = "BERENANG" Else hobi1 = ""
If chkhobby(2).Value = 1 Then hobi2 = "MAKAN" Else hobi2 = ""
If chkhobby(3).Value = 1 Then hobi3 = "NONTON" Else hobi3 = ""
If chkhobby(4).Value = 1 Then hobi4 = "BELANJA" Else hobi4 = ""



If st = "K" And jk = "L" Then tunjanganperanak = 70000: tunjanganistri = 90000: potongan = 15000 '====JIKA STATUS KAWIN DAN LAKI-LAKI
If st = "K" And jk = "P" Then tunjanganperanak = 50000: tunjanganistri = 0: potongan = 25000 '====JIKA STATUS KAWIN DAN PEREMPUAN
If st = "TK" And jk = "P" Then tunjanganperanak = 0: tunjanganistri = 0: potongan = 35000 '====JIKA STATUS TIDAK KAWIN DAN PEREMPUAN
If st = "TK" And jk = "L" Then tunjanganperanak = 0: tunjanganistri = 0: potongan = 40000 '====JIKA STATUS TIDAK KAWIN DAN LAKI-LAKI



For i = 1 To 1
nip = txtnip
nama = txtnama
List.FontBold = True
List.AddItem "NIP : " & nip
List.AddItem "NAMA : " & nama
List.AddItem "GOLONGAN : " & gol
List.AddItem "JENIS KELAMIN : " & cmbjenkel
List.AddItem "STATUS : " & cmbstatus
List.AddItem "HOBBY : " & hobi0 + " " + hobi1 + " " + hobi2 + " " + hobi3 + " " + hobi4
List.AddItem "GAJI POKOK : " & gapok
List.AddItem "TUNJANGAN ANAK : " & Format(tunjanganperanak, "#,##0")
List.AddItem "TUNJANGAN ISTRI : " & Format(tunjanganistri, "#,##0")
List.AddItem "POTONGAN : " & Format(potongan, "#,##0")
List.AddItem "GAJI BERSIH : " & Format((gapok + tunjanganperanak + tunjanganistri) - potongan, "#,##0")
Next i


End Sub

Private Sub cmdkeluar_Click()
End
End Sub

Public Sub cleartext(myform As Form)
Dim x As Control
For Each x In myform
If TypeOf x Is TextBox Then x.Text = ""
Next
For Each x In myform
If TypeOf x Is ComboBox Then x.ListIndex = -1
Next
For Each x In myform
If TypeOf x Is CheckBox Then x.Value = 0
Next
End Sub

Private Sub optgol_Click(Index As Integer)

'//////////////GAJI POKOK/////////////////////

Select Case Index
Case 0
'====JIKA GOLONGAN A
gol = "A"
gapok = 1000000
Case 1
'====JIKA GOLONGAN B
gol = "B"
gapok = 800000
Case Else
'====JIKA GOLONGAN C
gol = "C"
gapok = 600000
End Select
End Sub










<<<<<<<<<<<<<<<<<<<< Hasil >>>>>>>>>>>>>>>>>>>>