Dibawah ini adalah contoh pemrograman dasar Vb.net 2008 tentang penginputan nilai mahasiswa kedalam ListView
Public Class Form1
Sub BuatTabel()
LV.Columns.Add("NPM", 80, HorizontalAlignment.Center)
LV.Columns.Add("NAMA", 120, HorizontalAlignment.Center)
LV.Columns.Add("JURUSAN", 130, HorizontalAlignment.Center)
LV.Columns.Add("JENJANG", 80, HorizontalAlignment.Center)
LV.Columns.Add("TAHUN MASUK", 120, HorizontalAlignment.Center)
LV.Columns.Add("NILAI ANGKA", 120, HorizontalAlignment.Center)
LV.Columns.Add("NILAI HURUF", 120, HorizontalAlignment.Center)
LV.View = View.Details
LV.GridLines = True
LV.FullRowSelect = True
End Sub
Sub IsiTabel()
Dim isi As New ListViewItem
isi.Text = txtNpm.Text
isi.SubItems.Add(txtNama.Text)
isi.SubItems.Add(txtJurusan.Text)
isi.SubItems.Add(txtJenjang.Text)
isi.SubItems.Add(txtTahunMasuk.Text)
isi.SubItems.Add(txtNilaiAngka.Text)
isi.SubItems.Add(txtNilaiHuruf.Text)
LV.Items.Add(isi)
End Sub
Sub bersih()
txtNpm.Text = ""
txtNama.Text = ""
txtJurusan.Text = ""
txtJenjang.Text = ""
txtTahunMasuk.Text = ""
txtNilaiAngka.Text = ""
txtNilaiHuruf.Text = ""
End Sub
Sub nilai()
Select Case txtNilaiAngka.Text
Case Is >= 80
txtNilaiHuruf.Text = "A"
Case 70 To 79
txtNilaiHuruf.Text = "B"
Case 60 To 69
txtNilaiHuruf.Text = "C"
Case 50 To 59
txtNilaiHuruf.Text = "D"
Case Is <= 49
txtNilaiHuruf.Text = "E"
End Select
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Call BuatTabel()
End Sub
Private Sub txtNpm_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtNpm.TextChanged
Dim a, b, c As String
a = txtNpm.Text
txtTahunMasuk.Text = "20" & Microsoft.VisualBasic.Left(a, 2)
If a = "" Then
txtTahunMasuk.Clear()
End If
b = Microsoft.VisualBasic.Mid(a, 3, 1)
txtJenjang.Text = IIf(b = "1", "STRATA 1", _
IIf(b = "2", "DIPLOMA II", _
IIf(b = "3", "DIPLOMA III", "")))
c = Microsoft.VisualBasic.Mid(a, 4, 2)
txtJurusan.Text = IIf(c = "10", "TEKNIK INFORMATIKA", _
IIf(c = "12", "MANAJEMEN INFORMATIKA", _
IIf(c = "13", "SISTEM INFORMASI", "")))
End Sub
Private Sub txtNilaiAngka_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtNilaiAngka.KeyPress
Dim tombol As Integer = Asc(e.KeyChar)
If tombol = 13 Then
Call nilai()
ElseIf txtNilaiAngka.Text = "" Then
txtNilaiHuruf.Clear()
End If
End Sub
Private Sub txtNama_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtNama.KeyPress
Dim tombol As Integer = Asc(e.KeyChar)
If tombol = 13 Then
txtNilaiAngka.Focus()
End If
End Sub
Private Sub btnSimpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSimpan.Click
Call IsiTabel()
Call bersih()
txtNpm.Focus()
End Sub
Private Sub btnBersih_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBersih.Click
Call bersih()
txtNpm.Focus()
End Sub
Private Sub btnHapusSemua_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnHapusSemua.Click
LV.Items.Clear()
txtNpm.Focus()
End Sub
Private Sub btnPilihDihapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPilihDihapus.Click
LV.Items.Remove(LV.FocusedItem)
txtNpm.Focus()
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
hasil :
JAWABAN QUIZ HARI SENIN NO 2
klik disini untuk kasus [...]
Tidak ada komentar:
Posting Komentar