Selasa, 17 Januari 2012

Tugas LISTVIEW smester III

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(jenjang.Text)
            .SubItems.Add(jurusan.Text)
            .SubItems.Add(tahunmasuk.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 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 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
        npm.Text = ""
        nama.Text = ""
        jenjang.Text = ""
        jurusan.Text = ""
        tahunmasuk.Text = ""
        angka.Text = ""
        huruf.Text = ""

    End Sub
End Class


HASIL



Tidak ada komentar:

Posting Komentar