Kamis, 19 Januari 2012

latihan vb 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(tahun.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 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 btnsimpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsimpan.Click
        IsiTabel()
    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 = ""
        tahun.Text = ""
        angka.Text = ""
        huruf.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 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 angka_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles angka.TextChanged
      
        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 huruf_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles huruf.TextChanged

    End Sub

    Private Sub Label8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label8.Click

    End Sub
End Class