Saturday, 6 December 2014

belajar pemograman visual basic

Form table nilai mahasiswa










Public Class Form1
    Sub buattable()
        lv.Columns.Add("npm", 80, HorizontalAlignment.Center)
        lv.Columns.Add("nama", 120, HorizontalAlignment.Center)
        lv.Columns.Add("mkuliah", 140, HorizontalAlignment.Center)
        lv.Columns.Add("nuts", 80, HorizontalAlignment.Center)
        lv.Columns.Add("nuas", 120, HorizontalAlignment.Center)
        lv.view = View.details
        lv.gridlines = True
        lv.fullrowselect = True
    End Sub
    Sub isitable()
        Dim isi As New ListViewItem
        isi.Text = npm.Text
        isi.SubItems.Add(nama.Text)
        isi.SubItems.Add(mkuliah.Text)
        isi.SubItems.Add(nuts.Text)
        isi.SubItems.Add(nuas.Text)
        lv.Items.Add(isi)

    End Sub
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        buattable()
        npm.Items.Add("13111052")
        npm.Items.Add("13111062")
        npm.Items.Add("13111110")
        mkuliah.Items.Add("pemograman visual")
        mkuliah.Items.Add("sistem basis data")
        mkuliah.Items.Add("struktur data")
      


    End Sub

  
    Private Sub nuts_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles nuts.TextChanged
       
    End Sub

    Private Sub npm_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles npm.SelectedIndexChanged
        If npm.Text = "13111052" Then
            nama.Text = "sabam"
        ElseIf npm.Text = "13111062" Then
            nama.Text = "abdul"
        Else
            npm.Text = "13111356"
            nama.Text = "rini"
        End If
    End Sub

    Private Sub Btnproses_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnproses.Click
        nangka.Text = 0.4 * nuts.Text + 0.6 * nuas.Text
        If nangka.Text >= 80 Then
            nhuruf.Text = "A"
        ElseIf nangka.Text >= 70 Then
            nhuruf.Text = "B"
        ElseIf nangka.Text > 60 Then
            nhuruf.Text = "C"
        ElseIf nangka.Text > 50 Then
            nhuruf.Text = "D"
        Else
            nhuruf.Text = "E"
        End If
       

    End Sub

    Private Sub Btnisilist_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnisilist.Click
        isitable()
        npm.Text = ""
        nama.Text = ""
        mkuliah.Text = ""
        nuts.Text = ""
        nuas.Text = ""
        nangka.Text = ""
        nhuruf.Text = ""

    End Sub

    Private Sub Btnhapusnpm_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnhapusnpm.Click
        lv.Items.Remove(lv.SelectedItems(0))
    End Sub

    Private Sub Btnhapuslist_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnhapuslist.Click
        lv.Items.Clear()
    End Sub

    Private Sub Btnhapusdata_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnhapusdata.Click
        lv.Items.Clear()
    End Sub

    Private Sub Btnkeluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnkeluar.Click
        Me.Close()

    End Sub
End Class