Judul soal: Latihan Listview Penjualan Barang
Desain form berikut :
Program Listviewnya:
Public Class Form1
Sub buattabel()
LV.Columns.Add("NPM", 80, HorizontalAlignment.Center)
LV.Columns.Add("Nama", 100, HorizontalAlignment.Left)
LV.Columns.Add("Jenjang", 50, HorizontalAlignment.Left)
LV.Columns.Add("Jurusan", 70, HorizontalAlignment.Center)
LV.Columns.Add("Nama Dosen", 80, HorizontalAlignment.Center)
LV.Columns.Add("Mata Kuliah", 100, HorizontalAlignment.Center)
LV.Columns.Add("Nilai Akhir", 70, HorizontalAlignment.Center)
LV.Columns.Add("Nilai Huruf", 80, HorizontalAlignment.Center)
LV.Columns.Add("Keterangan", 80, HorizontalAlignment.Center)
LV.View = View.Details
LV.GridLines = True
LV.FullRowSelect = True
End Sub
Sub isitabel()
Dim lst As New ListViewItem
lst.Text = NPM.Text
lst.SubItems.Add(Nama.Text)
lst.SubItems.Add(Jenjang.Text)
lst.SubItems.Add(Jurusan.Text)
lst.SubItems.Add(M_Kuliah.Text)
lst.SubItems.Add(Nama_dosen.Text)
lst.SubItems.Add(Nilai_akhir.Text)
lst.SubItems.Add(Nilai_huruf.Text)
lst.SubItems.Add(Keterangan.Text)
LV.Items.Add(lst)
End Sub
Private Sub Btnproses_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnproses.Click
Nilai_akhir.Text = 0.1 * Nilai_kehadiran.Text + 0.15 * Nilai_tugas.Text + 0.3 * Nilai_UTS.Text + 0.45 * Nilai_UAS.Text
Select Case Nilai_akhir.Text
Case Is >= 80
Nilai_huruf.Text = "A"
Keterangan.Text = "LULUS"
Case 70 To 79
Nilai_huruf.Text = "B"
Keterangan.Text = "LULUS"
Case 60 To 69
Nilai_huruf.Text = "C"
Keterangan.Text = "GAGAL"
Case 50 To 59
Nilai_huruf.Text = "D"
Keterangan.Text = "GAGAL"
Case Is <= 49
Nilai_huruf.Text = "E"
Keterangan.Text = "GAGAL"
End Select
Nilai_akhir.Enabled = False
isitabel()
Nilai_huruf.Text = ""
Keterangan.Text = ""
Nama.Text = ""
NPM.Text = ""
Jurusan.Text = ""
Jenjang.Text = ""
Nama_dosen.Text = ""
Nilai_akhir.Text = ""
M_Kuliah.Text = ""
Nilai_kehadiran.Text = ""
Nilai_tugas.Text = ""
Nilai_UTS.Text = ""
Nilai_UAS.Text = ""
Kode_dosen.Text = ""
Kode_matakuliah.Text = ""
End Sub
Private Sub Btnhapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnhapus.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 Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
buattabel()
NPM.Items.Add("12110574")
NPM.Items.Add("12110161")
NPM.Items.Add("12110741")
NPM.Items.Add("12110927")
NPM.Items.Add("1202208")
Dim i As Integer
For i = 100 To 1 Step -5
Nilai_kehadiran.Items.Add(i)
Next
For i = 100 To 1 Step -5
Nilai_tugas.Items.Add(i)
Next
For i = 100 To 1 Step -5
Nilai_UTS.Items.Add(i)
Next
For i = 100 To 1 Step -5
Nilai_UAS.Items.Add(i)
Next i
Kode_matakuliah.Items.Add("123")
Kode_matakuliah.Items.Add("456")
Kode_matakuliah.Items.Add("789")
Kode_matakuliah.Items.Add("012")
Kode_dosen.Items.Add("012")
Kode_dosen.Items.Add("345")
Kode_dosen.Items.Add("678")
Kode_dosen.Items.Add("901")
Nilai_akhir.Enabled = False
End Sub
Private Sub Kode_matakuliah_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Kode_matakuliah.SelectedIndexChanged
Select Case Kode_matakuliah.Text
Case "123"
M_Kuliah.Text = "Visual Basic"
Case "456"
M_Kuliah.Text = "Matriks"
Case "789"
M_Kuliah.Text = "arsitektur dan organisasi kom"
Case "012"
M_Kuliah.Text = "struktur data"
End Select
Nilai_akhir.Enabled = False
End Sub
Private Sub Kode_dosen_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Kode_dosen.SelectedIndexChanged
Select Case Kode_dosen.Text
Case "012"
Nama_dosen.Text = "Mesran"
Case "345"
Nama_dosen.Text = "Kennedi Tampubolon"
Case "678"
Nama_dosen.Text = "Pilipus tarigan."
Case "901"
Nama_dosen.Text = "alex riki s."
End Select
End Sub
Private Sub Nilai_akhir_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Nilai_akhir.KeyPress
If Asc(e.KeyChar) = 13 Then
Nilai_akhir.Text = 0.1 * Nilai_kehadiran.Text + 0.15 * Nilai_tugas.Text + 0.3 * Nilai_UTS.Text + 0.45 * Nilai_UAS.Text
Nilai_akhir.Enabled = False
End If
End Sub
Private Sub NPM_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NPM.SelectedIndexChanged
Select Case NPM.Text
Case "12110161"
Nama.Text = " Anisah H"
Jenjang.Text = "S1"
Jurusan.Text = "TI"
Case "12110741"
Nama.Text = "TIKA H"
Jenjang.Text = "D3"
Jurusan.Text = "MI"
Case "12110574"
Nama.Text = "EKO"
Jenjang.Text = "S1"
Jurusan.Text = "TI"
Case "12110927"
Nama.Text = " JUNI Sihombing"
Jenjang.Text = "S1"
Jurusan.Text = "SI"
Case "1202208"
Nama.Text = "Septriani Simanjuntak"
Jenjang.Text = "D3"
Jurusan.Text = "KA"
End Select
End Sub
End Class
Demikian hasil nya :
Semoga bermanfaat bagi anda...
Demikian postingan saya :
Nama: Anisah harahap
NPM : 12110161