Rabu, 18 Januari 2012

TUGAS LISTVIEW

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(JENJANG.Text)
            .SubItems.Add(JURUSAN.Text)
            .SubItems.Add(THNMASUK.Text)
            .SubItems.Add(NILANGKA.Text)
            .SubItems.Add(NILHURUF.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 As String
        X = Microsoft.VisualBasic.Mid(NPM.Text, 3, 1)
        Y = Microsoft.VisualBasic.Mid(NPM.Text, 4, 1)
        If X = "0" Then
            If Y = "2" Then
                JENJANG.Text = "D3"
                JURUSAN.Text = "Manajemen Informatika"
            End If
        ElseIf X = "1" Then
            JENJANG.Text = "S1"
            If Y = "1" Then
                JURUSAN.Text = "Tek.Informatika"
            ElseIf Y = "2" Then
                JURUSAN.Text = "Sis.Informasi"
            End If
        End If
    End Sub


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

    End Sub

    Sub CariNilai()
        If NILANGKA.Text >= 85 Then
            NILHURUF.Text = "A"
        ElseIf NILANGKA.Text >= 75 Then
            NILHURUF.Text = "B"
        ElseIf NILANGKA.Text >= 70 Then
            NILHURUF.Text = "C"
        ElseIf NILANGKA.Text >= 60 Then
            NILHURUF.Text = "D"
        Else
            NILHURUF.Text = "E"
        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 BTNBERSIH_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNBERSIH.Click
        NPM.Text = ""
        NAMA.Text = ""
        JENJANG.Text = ""
        JURUSAN.Text = ""
        THNMASUK.Text = ""
        NILANGKA.Text = ""
        NILHURUF.Text = ""
    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
End Class

HASIL...........

1 komentar: