Penggunaan fungsi If dan looping adalah pelajaran sederhana dalam pemogroman, karena disini lah awal dari kesempurnaan progam. Kami berharap Semoga program fungsi If dan looping dapat bermanfaat bagi para programer dasar.
listing Program penggunaan fungsi If dan looping:
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
makul.Items.Add("Pemrograman Visual I")
makul.Items.Add("Arsitektur dan Organisasi Komputer")
makul.Items.Add("Sistem Operasi")
makul.Items.Add("Struktur Data")
makul.Items.Add("Komunikasi Data")
makul.Items.Add("Agama Islam")
dosen.Items.Add("Mesran, S.Kom, M.Kom")
dosen.Items.Add("Philipus Tarigan, S.T, M.Kom")
dosen.Items.Add("Abdul Sani Sembiring, S.Kom, M.Kom")
dosen.Items.Add("Alex Rikki, S.Kom, M.Kom")
dosen.Items.Add("Agus Setiawan")
dosen.Items.Add("Fitri Handasari, S.Kom")
npm.Items.Add("12110102")
npm.Items.Add("12110046")
npm.Items.Add("12110144")
npm.Items.Add("12110177")
npm.Items.Add("12110897")
na.Enabled = False
KETERANGAN.Enabled = False
nama.Enabled = False
Dim i As Integer
For i = 100 To 1 Step -1
Nk.Items.Add(i)
Next
i = 100
For i = 100 To 1 Step -1
Ntug.Items.Add(i)
Next
i = 100
For i = 100 To 1 Step -1
nmid.Items.Add(i)
Next
i = 100
For i = 100 To 1 Step -1
nsem.Items.Add(i)
Next
i = 100
End Sub
Private Sub B_hapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B_hapus.Click
makul.Text = ""
dosen.Text = ""
Nk.Text = ""
Ntug.Text = ""
nmid.Text = ""
nsem.Text = ""
na.Text = ""
nama.Text = ""
npm.Text = ""
KETERANGAN.Text = ""
End Sub
Private Sub B_keluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B_keluar.Click
Me.Close()
End Sub
Private Sub B_proses_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B_proses.Click
na.Text = 0.1 * Nk.Text + 0.15 * Ntug.Text + 0.3 * nmid.Text + 0.45 * nsem.Text
If nsem.Text >= 50 Then
KETERANGAN.Text = "LULUS"
Else
KETERANGAN.Text = "GAGAL"
End If
End Sub
Private Sub npm_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles npm.SelectedIndexChanged
If npm.Text = "12110102" Then
nama.Text = "Jailamm Igaph S"
ElseIf npm.Text = "12110044" Then
nama.Text = "Chanif Arvani"
ElseIf npm.Text = "12110046" Then
nama.Text = "Agus Setiawan"
ElseIf npm.Text = "12110177" Then
nama.Text = "Reza Ariansyah"
ElseIf npm.Text = "121100333" Then
nama.Text = "Enma Syahputri"
Else
nama.Text = "Chanif Arvani"
End If
End Sub
Private Sub nsem_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs)
If Asc(e.KeyChar) = 13 Then
na.Text = 0.1 * Nk.Text + 0.15 * Ntug.Text + 0.3 * nmid.Text + 0.45 * nsem.Text
End If
End Sub
End Class
From Aplikasi
listing Program penggunaan fungsi If dan looping:
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
makul.Items.Add("Pemrograman Visual I")
makul.Items.Add("Arsitektur dan Organisasi Komputer")
makul.Items.Add("Sistem Operasi")
makul.Items.Add("Struktur Data")
makul.Items.Add("Komunikasi Data")
makul.Items.Add("Agama Islam")
dosen.Items.Add("Mesran, S.Kom, M.Kom")
dosen.Items.Add("Philipus Tarigan, S.T, M.Kom")
dosen.Items.Add("Abdul Sani Sembiring, S.Kom, M.Kom")
dosen.Items.Add("Alex Rikki, S.Kom, M.Kom")
dosen.Items.Add("Agus Setiawan")
dosen.Items.Add("Fitri Handasari, S.Kom")
npm.Items.Add("12110102")
npm.Items.Add("12110046")
npm.Items.Add("12110144")
npm.Items.Add("12110177")
npm.Items.Add("12110897")
na.Enabled = False
KETERANGAN.Enabled = False
nama.Enabled = False
Dim i As Integer
For i = 100 To 1 Step -1
Nk.Items.Add(i)
Next
i = 100
For i = 100 To 1 Step -1
Ntug.Items.Add(i)
Next
i = 100
For i = 100 To 1 Step -1
nmid.Items.Add(i)
Next
i = 100
For i = 100 To 1 Step -1
nsem.Items.Add(i)
Next
i = 100
End Sub
Private Sub B_hapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B_hapus.Click
makul.Text = ""
dosen.Text = ""
Nk.Text = ""
Ntug.Text = ""
nmid.Text = ""
nsem.Text = ""
na.Text = ""
nama.Text = ""
npm.Text = ""
KETERANGAN.Text = ""
End Sub
Private Sub B_keluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B_keluar.Click
Me.Close()
End Sub
Private Sub B_proses_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B_proses.Click
na.Text = 0.1 * Nk.Text + 0.15 * Ntug.Text + 0.3 * nmid.Text + 0.45 * nsem.Text
If nsem.Text >= 50 Then
KETERANGAN.Text = "LULUS"
Else
KETERANGAN.Text = "GAGAL"
End If
End Sub
Private Sub npm_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles npm.SelectedIndexChanged
If npm.Text = "12110102" Then
nama.Text = "Jailamm Igaph S"
ElseIf npm.Text = "12110044" Then
nama.Text = "Chanif Arvani"
ElseIf npm.Text = "12110046" Then
nama.Text = "Agus Setiawan"
ElseIf npm.Text = "12110177" Then
nama.Text = "Reza Ariansyah"
ElseIf npm.Text = "121100333" Then
nama.Text = "Enma Syahputri"
Else
nama.Text = "Chanif Arvani"
End If
End Sub
Private Sub nsem_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs)
If Asc(e.KeyChar) = 13 Then
na.Text = 0.1 * Nk.Text + 0.15 * Ntug.Text + 0.3 * nmid.Text + 0.45 * nsem.Text
End If
End Sub
End Class
Post a Comment