Yuk,, belajar Konsep Pemrograman Visual Basic:
contoh : Mencari form nilai
contoh : Mencari form nilai
By : Melpin
Hutauruk
1. Buatlah Form seperti gambar dibawah
ini:
2. Ketiklah listing seperti berikut
ini:
Public Class Form1
Private Sub Npm_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Npm.SelectedIndexChanged
Dim x As String
x = Microsoft.VisualBasic.Right(Npm.Text, 1)
If x = "0" Then
Jenjang.Text = "S1"
ElseIf x = "1" Then
Jenjang.Text = "D3"
Else
Jenjang.Text = "D1"
End If
x = Microsoft.VisualBasic.Mid(Npm.Text, 4, 2)
If x = "10" Then
Jurusan.Text = "Teknik Informatika"
ElseIf x = "11" Then
Jurusan.Text = "Sistem Informasi"
ElseIf x = "12" Then
Jurusan.Text = "Manajemen"
Else
Jurusan.Text = "-"
End If
Select Case Npm.Text
Case "12110540"
Nama.Text = " Melpin Hutauruk"
Case "12110541"
Nama.Text = "Anisah "
Case "12110542"
Nama.Text = "Lista"
Case Else
Nama.Text = "-"
End Select
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 "KD001"
Nama_dosen.Text = "Mesran, S.Kom, M.Kom"
Case "KD002"
Nama_dosen.Text = "Yasir Hasan, S.Kom"
Case "KD003"
Nama_dosen.Text = "Sinar Sinurat, ST, M.Kom"
Case Else
Nama_dosen.Text = "Sony Bahagia Sinaga, M.Kom"
End Select
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 "KM001"
Nama_matakuliah.Text = "PEMOGRAMAN VISUAL"
Case "KM002"
Nama_matakuliah.Text = "SISTEM BASIS DATA"
Case "KM003"
Nama_matakuliah.Text = "STRUKTUR DATA"
Case Else
Nama_matakuliah.Text = "KOMUNIKASI DATA"
End Select
End Sub
Private Sub Btnhapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnhapus.Click
Npm.Text = ""
Nama.Text = ""
Jenjang.Text = ""
Jurusan.Text = ""
Nama_dosen.Text = ""
Nama_matakuliah.Text = ""
NA.Text = ""
NH.Text = ""
Keterangan.Text = ""
N_UTS.Text = ""
N_UAS.Text = ""
N_Tugas.Text = ""
Kode_matakuliah.Text = ""
Kode_dosen.Text = ""
Nilai_kehadiran.Text = ""
End Sub
Private Sub Btnproses_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnproses.Click
NA.Text = 0.1 * Nilai_kehadiran.Text + 0.15 * N_Tugas.Text + 0.3 * N_UTS.Text + 0.45 * N_UAS.Text
If NA.Text >= 50 Then
Keterangan.Text = "LULUS"
Else
Keterangan.Text = "GAGAL"
End If
If NA.Text >= 80 Then
NH.Text = "A"
ElseIf NA.Text >= 70 Then
NH.Text = "B"
ElseIf NA.Text >= 60 Then
NH.Text = "C"
ElseIf NA.Text >= 50 Then
NH.Text = "D"
Else
NH.Text = "E"
End If
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
Npm.Items.Add("12110540")
Npm.Items.Add("12110541")
Npm.Items.Add("12110542")
Kode_dosen.Items.Add("KD001")
Kode_dosen.Items.Add("KD002")
Kode_dosen.Items.Add("KD003")
Kode_matakuliah.Items.Add("KM001")
Kode_matakuliah.Items.Add("KM002")
Kode_matakuliah.Items.Add("KM003")
Dim i As Integer
For i = 1 To 100
Nilai_kehadiran.Items.Add(i)
Next i
i = 100
For i = 1 To 100
N_Tugas.Items.Add(i)
Next i
i = 100
For i = 1 To 100
N_UTS.Items.Add(i)
Next i
For i = 1 To 100
N_UAS.Items.Add(i)
Next i
End Sub
End Class
3. Tekan F5/ Debug pilih start debuging untuk melihat hasil , maka hasilnya seperti gambar dibawah ini :
Selamat mencoba..... bagi anda para
pembaca, semoga artikel ini bermanfaat . Kritik dan saran anda sangat saya
hargai . Terimakasih......:)