Sabtu, 28 Januari 2012

jawaban soal no.3

 KASUS
soal no.3(penggajian karyawan)

LISTING PROGRAM

Public Class PEGAWAI

    Private Sub PEGAWAI_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        BuatTabel()
        JABATAN.Items.Add("MANDOR")
        JABATAN.Items.Add("KABAG")
        JABATAN.Items.Add("STAFF")
        STATUS.Items.Add("MENIKAH")
        STATUS.Items.Add("TIDAK MENIKAH")
    End Sub
    Sub BuatTabel()
        With LV()
            .Columns.Add("NAMA", 100, HorizontalAlignment.Center)
            .Columns.Add("JABATAN", 120, HorizontalAlignment.Left)
            .Columns.Add("GAJI", 100, HorizontalAlignment.Left)
            .Columns.Add("STATUS", 100, HorizontalAlignment.Left)
            .Columns.Add("JUMLAH ANAK", 80, HorizontalAlignment.Left)
            .Columns.Add("TUNJANGAN ANAK", 120, HorizontalAlignment.Left)
            .Columns.Add("JAM", 80, HorizontalAlignment.Left)
            .Columns.Add("LEMBUR", 110, HorizontalAlignment.Left)
            .Columns.Add("TUNJANGAN ISTRI", 120, HorizontalAlignment.Left)
            .Columns.Add("PAJAK", 80, HorizontalAlignment.Left)
            .Columns.Add("TOTAL GAJI", 80, HorizontalAlignment.Left)
            .GridLines = True
            .FullRowSelect = True
            .View = View.Details
        End With
    End Sub
    Sub IsiTabel()
        Dim Lst As New ListViewItem
        With Lst
            .Text = NAMA.Text
            .SubItems.Add(JABATAN.Text)
            .SubItems.Add(GAJI.Text)
            .SubItems.Add(STATUS.Text)
            .SubItems.Add(JLHANAK.Text)
            .SubItems.Add(TUNJANGANANAK.Text)
            .SubItems.Add(JAM.Text)
            .SubItems.Add(LEMBUR.Text)
            .SubItems.Add(TUNJANGANISTRI.Text)
            .SubItems.Add(PAJAK.Text)
            .SubItems.Add(TTLGAJI.Text)
            LV.Items.Add(Lst)
        End With
    End Sub

    Private Sub JABATAN_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles JABATAN.SelectedIndexChanged
        If JABATAN.Text = "MANDOR" Then
            GAJI.Text = 175000
        ElseIf JABATAN.Text = "KABAG" Then
            GAJI.Text = 2500000
        ElseIf JABATAN.Text = "STAFF" Then
            GAJI.Text = 1250000
        Else
            GAJI.Text = " "
        End If
    End Sub

    Private Sub STATUS_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles STATUS.SelectedIndexChanged
        If STATUS.Text = "MENIKAH" Then
            TUNJANGANISTRI.Text = 9 * GAJI.Text / 100
            PAJAK.Text = 1.5 * GAJI.Text / 100
        ElseIf STATUS.Text = "TIDAK MENIKAH" Then
            TUNJANGANANAK.Text = 0
            TUNJANGANISTRI.Text = 0
            PAJAK.Text = 1.5 * GAJI.Text / 100
        Else
            STATUS.Text = " "
        End If
    End Sub
   
    Private Sub JAM_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles JAM.TextChanged
        If JABATAN.Text = "MANDOR" Then
            LEMBUR.Text = Val(JAM.Text) * 7500
        ElseIf JABATAN.Text = "KABAG" Then
            LEMBUR.Text = Val(JAM.Text) * 10000
        ElseIf JABATAN.Text = "STAFF" Then
            LEMBUR.Text = Val(JAM.Text) * 5000
        End If
    End Sub

    Private Sub JLANAK_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles JLHANAK.TextChanged
        If Val(JLHANAK.Text) = 1 Then
            TUNJANGANANAK.Text = 3 * GAJI.Text / 100
        ElseIf Val(JLHANAK.Text) >= 2 Then
            TUNJANGANANAK.Text = 7 * GAJI.Text / 100
        End If
    End Sub
    Sub PROSES()
        TTLGAJI.Text = Val(GAJI.Text) + Val(TUNJANGANISTRI.Text) + Val(TUNJANGANANAK.Text) + Val(LEMBUR.Text) - Val(PAJAK.Text)
    End Sub
    Private Sub BTNTOTAL_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNTOTAL.Click
        Call PROSES()
    End Sub

    Private Sub BTNSIMPAN_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNSIMPAN.Click
        IsiTabel()
    End Sub

    Private Sub BTNHAPUS_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNHAPUS.Click
        LV.Items.Clear()
    End Sub

    Private Sub BTNDATA_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNDATA.Click
        LV.Items.Remove(LV.SelectedItems(0))
    End Sub

    Private Sub BTNKELUAR_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNKELUAR.Click
        End
    End Sub

    Private Sub BTNBERSIH_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNBERSIH.Click
        NAMA.Text = ""
        JABATAN.Text = ""
        STATUS.Text = ""
        GAJI.Text = ""
        JLHANAK.Text = ""
        TUNJANGANANAK.Text = ""
        JAM.Text = ""
        LEMBUR.Text = ""
        TUNJANGANISTRI.Text = ""
        PAJAK.Text = ""
        TTLGAJI.Text = ""
    End Sub
End Class

HASIL PROGRAM




jawaban soal No.2 (hal 33)

KASUS
soal no.2(modul hal 33)


LISTING PROGRAM..

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        BuatTabel()
        kodbrg.Items.Add("TS001")
        kodbrg.Items.Add("TS002")
        kodbrg.Items.Add("VG001")
        kodbrg.Items.Add("VG002")
    End Sub
    Sub BuatTabel()
        With LV
            .Columns.Add("No Pembelian", 80, HorizontalAlignment.Center)
            .Columns.Add("Kode Barang", 120, HorizontalAlignment.Left)
            .Columns.Add("Nama Barang", 100, HorizontalAlignment.Left)
            .Columns.Add("Merk", 100, HorizontalAlignment.Left)
            .Columns.Add("Harga", 100, HorizontalAlignment.Left)
            .Columns.Add("Jumlah Beli", 80, HorizontalAlignment.Left)
            .Columns.Add("Total Harga", 80, HorizontalAlignment.Left)
            .GridLines = True
            .FullRowSelect = True
            .View = View.Details
        End With
    End Sub
    Sub IsiTabel()
        Dim Lst As New ListViewItem
        With Lst
            .Text = pembelian.Text()
            .SubItems.Add(kodbrg.Text)
            .SubItems.Add(nmbrg.Text)
            .SubItems.Add(merk.Text)
            .SubItems.Add(harga.Text)
            .SubItems.Add(jlhbeli.Text)
            .SubItems.Add(ttlhrg.Text)
            LV.Items.Add(Lst)
        End With
    End Sub

    Private Sub kodbrg_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kodbrg.SelectedIndexChanged
        Dim x As String
        x = Microsoft.VisualBasic.Left(kodbrg.Text, 2)
        Select Case x
            Case "TS" : merk.Text = "Toshiba"
            Case "VG" : merk.Text = "V-Gen"
        End Select
        x = Microsoft.VisualBasic.Right(kodbrg.Text, 3)
        Select Case x
            Case "001" : nmbrg.Text = "Flashdisk 4GB"
            Case "002" : nmbrg.Text = "Flashdisk 2GB"
        End Select
        If kodbrg.Text = "TS001" Then
            harga.Text = 105000
        ElseIf kodbrg.Text = "TS002" Then
            harga.Text = 75000
        End If
        If kodbrg.Text = "VG001" Then
            harga.Text = 90000
        ElseIf kodbrg.Text = "VG002" Then
            harga.Text = 60000
        End If

    End Sub

    Private Sub btnsimpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsimpan.Click
        IsiTabel()
    End Sub

    Private Sub btnhapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnhapus.Click
        LV.Items.Clear()
    End Sub

    Private Sub btndata_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btndata.Click
        LV.Items.Remove(LV.SelectedItems(0))
    End Sub

    Private Sub btnbersih_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnbersih.Click
        pembelian.Text = ""
        kodbrg.Text = ""
        nmbrg.Text = ""
        merk.Text = ""
        harga.Text = ""
        jlhbeli.Text = ""
        ttlhrg.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 jlhbeli_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles jlhbeli.TextChanged
        ttlhrg.Text = Val(jlhbeli.Text) * Val(harga.Text)
    End Sub
End Class

HASIL PROGRAM...



Sabtu, 21 Januari 2012

MEMBUAT MENU PADA VB NET DENGAN LISTVIEW

1.DESIGN FORM LOGIN


 2. LISTING PROGRAM
Public Class Form1


    Private Sub BTNOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNOK.Click
        If username.Text = "ANDARI" And password.Text = "111" Then
            MsgBox("Wellcome")
            MENUUTAMA.Show()
            Me.Hide()
        Else
            MsgBox("Maaf Username / Password Salah !")
            username.Text = ""
            password.Text = ""
        End If
    End Sub


    Private Sub BTNKELUAR_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNKELUAR.Click
        End
    End Sub


    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load


    End Sub
End Class

3. BUAT FORM BARU (MENUUTAMA)


4.LISTING PROGRAM

Public Class MENUUTAMA


    Private Sub DATAPEGAWAIToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DATAPEGAWAIToolStripMenuItem.Click
        PEGAWAI.SHOW()
    End Sub


    Private Sub KELUARToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KELUARToolStripMenuItem.Click
        End
    End Sub


    Private Sub MENUUTAMA_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load


    End Sub
End Class

5. BUAT FORM BARU LAGI (PEGAWAI)


6. LISTING PROGRAM

Public Class PEGAWAI


    Private Sub PEGAWAI_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        BuatTabel()
        NIP.Items.Add("001")
        NIP.Items.Add("002")
        NIP.Items.Add("003")
        GOL.Items.Add("IIIA")
        GOL.Items.Add("IIIB")
        GOL.Items.Add("IIIC")
        STATUS.Items.Add("MENIKAH")
        STATUS.Items.Add("TIDAK MENIKAH")
        JLHANAK.Items.Add("0")
        JLHANAK.Items.Add("1")
        JLHANAK.Items.Add("2")
        JLHANAK.Items.Add("3")
    End Sub
        Sub BuatTabel()
        With LV()
            .Columns.Add("NIP", 80, HorizontalAlignment.Center)
            .Columns.Add("NAMA", 120, HorizontalAlignment.Left)
            .Columns.Add("GOL", 100, HorizontalAlignment.Left)
            .Columns.Add("GAJI", 80, HorizontalAlignment.Left)
            .Columns.Add("STATUS", 100, HorizontalAlignment.Left)
            .Columns.Add("TUNJANGAN ANAK", 120, HorizontalAlignment.Left)
            .Columns.Add("TUNJANGAN KELUARGA", 150, HorizontalAlignment.Left)
            .Columns.Add("JUMLAH ANAK", 80, HorizontalAlignment.Left)
            .Columns.Add("PAJAK", 80, HorizontalAlignment.Left)
            .Columns.Add("TOTAL GAJI", 80, HorizontalAlignment.Left)
            .GridLines = True
            .FullRowSelect = True
            .View = View.Details
        End With
    End Sub
    Sub IsiTabel()
        Dim Lst As New ListViewItem
        With Lst
            .Text = NIP.Text(0)
            .SubItems.Add(NAMA.Text)
            .SubItems.Add(GOL.Text)
            .SubItems.Add(GAJI.Text)
            .SubItems.Add(STATUS.Text)
            .SubItems.Add(TUNJANGANANAK.Text)
            .SubItems.Add(TUNJANGANKELUARGA.Text)
            .SubItems.Add(JLHANAK.Text)
            .SubItems.Add(PAJAK.Text)
            .SubItems.Add(TTLGAJI.Text)
            LV.Items.Add(Lst)
        End With
    End Sub




    Private Sub NIP_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NIP.SelectedIndexChanged
        If NIP.Text = "001" Then
            NAMA.Text = "ANDARI"
        ElseIf NIP.Text = "002" Then
            NAMA.Text = "JUNADI"
        ElseIf NIP.Text = "003" Then
            NAMA.Text = "WINARI"
        Else
            NAMA.Text = " "
        End If


    End Sub


    Private Sub GOL_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GOL.SelectedIndexChanged
        If GOL.Text = "IIIA" Then
            GAJI.Text = 3000000
        ElseIf GOL.Text = "IIIB" Then
            GAJI.Text = 2500000
        ElseIf GOL.Text = "IIIC" Then
            GAJI.Text = 2000000
        Else
            GAJI.Text = " "
        End If
    End Sub


    Private Sub STATUS_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles STATUS.SelectedIndexChanged
        If STATUS.Text = "MENIKAH" Then
            TUNJANGANKELUARGA.Text = 5 * GAJI.Text / 100
            TUNJANGANANAK.Text = 7 * GAJI.Text / 100
            PAJAK.Text = 5 * GAJI.Text / 100
        ElseIf STATUS.Text = "TIDAK MENIKAH" Then
            TUNJANGANANAK.Text = 0
            TUNJANGANKELUARGA.Text = 0
        Else
            STATUS.Text = " "
        End If
        Call proses()
    End Sub
    Sub proses()
        TTLGAJI.Text = Val(GAJI.Text) + Val(TUNJANGANANAK.Text) + Val(TUNJANGANKELUARGA.Text) - Val(PAJAK.Text)
    End Sub


    Private Sub BTNSIMPAN_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNSIMPAN.Click
        IsiTabel()
    End Sub


    Private Sub BTNKELUAR_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNKELUAR.Click
        End
    End Sub
End Class

7.JALANKAN (TEKAN F5)

MAKA AKAN MUNCUL...


JIKA KITA KLIK OK
MAKA AKAN MUNCUL....


KLIK MENU FILE PILIH DATA PEGAWAI
DAN HASILNYA......

SELAMAT MENCOBA DAN SEMOGA BERHASIL........:-)


Selasa, 17 Januari 2012

TUGAS VISUAL BASIC LISTVIEW..

1.DESIGN FORM
2.LISTING PROGRAM

Public Class Form1
    Sub BuatTabel()
        With LV
            .Columns.Add("NPM", 80, HorizontalAlignment.Center)
            .Columns.Add("NAMA", 120, HorizontalAlignment.Left)
            .Columns.Add("JENJANG", 100, HorizontalAlignment.Left)
            .Columns.Add("JURUSAN", 100, HorizontalAlignment.Left)
            .Columns.Add("TAHUN MASUK", 100, HorizontalAlignment.Left)
            .Columns.Add("NILAI ANGKA", 80, HorizontalAlignment.Left)
            .Columns.Add("NILAI HURUF", 80, HorizontalAlignment.Left)
            .GridLines = True
            .FullRowSelect = True
            .View = View.Details
        End With
    End Sub
    Sub IsiTabel()
        Dim Lst As New ListViewItem
        With Lst
            .Text = NPM.Text(0)
            .SubItems.Add(NAMA.Text)
            .SubItems.Add(JNJNG.Text)
            .SubItems.Add(JRSN.Text)
            .SubItems.Add(THNMSK.Text)
            .SubItems.Add(ANGKA.Text)
            .SubItems.Add(HURUF.Text)
            LV.Items.Add(Lst)
        End With
    End Sub
   
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        BuatTabel()
    End Sub
    Private Sub NPM_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NPM.TextChanged
        Dim X, Y,Z As String
        X = Microsoft.VisualBasic.Mid(NPM.Text, 3, 1)
        Y = Microsoft.VisualBasic.Mid(NPM.Text, 4, 1)
        Z = Microsoft.VisualBasic.Left(NPM.Text, 2)
        If z = "10" Then
            THNMSK.Text = "2010"
        ElseIf z = "00" Then
            THNMSK.Text = "2009"
        End If
        If X = "0" Then
            If Y = "2" Then
                JNJNG.Text = "D3"
                JRSN.Text = "Manajemen Informatika"
            End If
        ElseIf X = "1" Then
            JNJNG.Text = "S1"
            If Y = "1" Then
                JRSN.Text = "Tek.Informatika"
            ElseIf Y = "2" Then
                JRSN.Text = "Sis.Informasi"
            End If

        End If
    End Sub

    Private Sub ANGKA_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles ANGKA.KeyPress
        Dim tombol As Integer = Asc(e.KeyChar)
        If tombol = 13 Then
            CariNilai()
        End If

    End Sub

    Sub CariNilai()
        If ANGKA.Text >= 85 Then
            HURUF.Text = "A"
        ElseIf ANGKA.Text >= 75 Then
            HURUF.Text = "B"
        ElseIf ANGKA.Text >= 70 Then
            HURUF.Text = "C"
        ElseIf ANGKA.Text >= 60 Then
            HURUF.Text = "D"
        Else
            HURUF.Text = "E"
        End If

    End Sub

    Private Sub BTNSMPN_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNSMPN.Click
        IsiTabel()
    End Sub

    Private Sub BTNHPS_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNHPS.Click
        LV.Items.Clear()
    End Sub

    Private Sub BTNDATA_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNDATA.Click
        LV.Items.Remove(LV.SelectedItems(0))
    End Sub

    Private Sub BTNKELUAR_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNKELUAR.Click
        End
    End Sub

    Private Sub BTNBRSH_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNBRSH.Click
        NPM.Text = ""
        NAMA.Text = ""
        JNJNG.Text = ""
        JRSN.Text = ""
        THNMSK.Text = ""
        ANGKA.Text = ""
        HURUF.Text = ""

    End Sub
End Class

3. HASILNYAA......

NB :

* Simpan ke ListView        :  membuat data ke dalam Tabel
* Bersih                             :  menghapus data yang telah kita buat
* Hapus Data yang di pilih  : menghapus data yang kita inginkan yang ada pada tabel
* hapus Semua data           : menghapus semua data yang terdapat dalam tabel
* Keluar                             : keluar dari program