Rabu, 18 Januari 2012

VB (Listview)


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 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
                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


Tidak ada komentar:

Posting Komentar