Belajar Bahasa Pemograman
Postingan ini saya buat untuk melengkapi tugas mata kuliah Pemograman Visual saya.. Disini saya akan membuat contoh form penggajian pegawai menggunakan Visula Basic..
Pertama dibuat dulu form seperti dibawah ini :
ComboBox
1
|
NIK
|
NIK
|
ComboBox
2
|
Jabatan
|
Jabatan
|
ComboBox
3
|
Status
|
Status
|
ComboBox
4
|
Jumlah Anak
|
JA
|
TextBox
1
|
Nama
|
nama
|
TextBox
2
|
Bagian
|
bagian
|
TextBox
3
|
Gaji Pokok
|
GP
|
TextBox
4
|
Pajak
|
pajak
|
TextBox
5
|
Tunjanga Keluarga
|
TK
|
TextBox
6
|
Tunjangan Anak
|
TA
|
TextBox
7
|
Total Gaji
|
TG
|
Button
1
|
Hapus
|
btnhapus
|
Button
2
|
Keluar
|
btnkeluar
|
Button
3
|
proses
|
btnproses
|
Gambar 1.1 Bentuk Form
Lalu isikan perintah dibawah ini untuk vb.design nya.
Private Sub NIK_SelectedIndexChanged(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles
NIK.SelectedIndexChanged
Select Case NIK.Text
Case
"PM010"
nama.Text = "Kristina Nancy Lumban Gaol"
Case
"PS111"
nama.Text = "Meitri widya"
Case
"KU101"
nama.Text = "Doni Armando"
Case
"GD100"
nama.Text = "Steven Leo"
Case
"PM011"
nama.Text = "Cahyo Sobirin"
End Select
Dim B As String
B = Microsoft.VisualBasic.Left(NIK.Text,
2)
Select Case B
Case
"PM"
bagian.Text = "Pemasaran"
Case
"PS"
bagian.Text = "Personalia"
Case
"KU"
bagian.Text = "Keuangan"
Case
"GD"
bagian.Text = "Gudang"
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
"Kepala Divisi"
GP.Text = "5000000"
Case
"Staf"
GP.Text = "2000000"
Case
"Wakil Kepala"
GP.Text = "3500000"
End Select
Pajak.Text = GP.Text * 0.1
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"
TK.Text = 0.15 * GP.Text
Case
"Belum Menikah"
TK.Text = 0
End Select
End Sub
Private Sub JA_SelectedIndexChanged(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles
JA.SelectedIndexChanged
Select Case JA.Text
Case
"1"
TA.Text = 0.5 * GP.Text
Case
"2"
TA.Text = 0.1 * GP.Text
Case
"3"
TA.Text = "Berlaku Untuk Dua Anak saja"
Case
"4"
TA.Text = "Berlaku Untuk Dua Anak saja"
End Select
End Sub
End Sub
Private Sub Form1_Load(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
NIK.Items.Add("PM010")
NIK.Items.Add("PS111")
NIK.Items.Add("KU101")
NIK.Items.Add("GD100")
NIK.Items.Add("PM011")
Jabatan.Items.Add("Kepala Divisi")
Jabatan.Items.Add("Staf")
Jabatan.Items.Add("Wakil Kepala")
Status.Items.Add("Menikah")
Status.Items.Add("Belum
Menikah")
Dim i As Integer
For i =
1 To 6
JA.Items.Add(i)
Next i
End Sub
Private Sub Btnproses_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles Btnproses.Click
TG.Text = Val(GP.Text) + Val(TA.Text) +
Val(TK.Text) - Pajak.Text
End Sub
Private Sub Btnhapus_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles Btnhapus.Click
NIK.Text = ""
nama.Text = ""
bagian.Text = ""
Jabatan.Text = ""
GP.Text = ""
Pajak.Text = ""
Status.Text = ""
JA.Text = ""
TA.Text = ""
TK.Text = ""
TG.Text = ""
End Sub
End Class
Dan inilah hasilnya :
Gambar 1.2. Hasil form apabila pegawai sudah menikah
Gambar 1.3. Hasil form apabila pegawai belum menikah
No comments:
Post a Comment
Silahkan tinggalkan komentar dibawah ini. Jadilah pembaca yang aktif. Gomawo ^^