Kasus 1
Berikut Source Codenya :
Public Class kasus1
'nadiahtami 2017230007
Sub agama()
ComboBox1.Items.Add("Islam")
ComboBox1.Items.Add("Hindu")
ComboBox1.Items.Add("Budha")
ComboBox1.Items.Add("Kristen")
End Sub
Sub jurusan()
ComboBox2.Items.Add("Teknik")
ComboBox2.Items.Add("Sastra")
ComboBox2.Items.Add("Manajemen")
ComboBox2.Items.Add("Kelautan")
End Sub
Sub programstudi()
ComboBox3.Items.Add("D3")
ComboBox3.Items.Add("D4")
ComboBox3.Items.Add("S1")
ComboBox3.Items.Add("S2")
ComboBox3.Items.Add("S3")
End Sub
Sub kota()
ListBox1.Items.Add("Bekasi")
ListBox1.Items.Add("Jakarta")
ListBox1.Items.Add("Semarang")
ListBox1.Items.Add("Yogyakarta")
ListBox1.Items.Add("Tegal")
ListBox1.Items.Add("Solo")
ListBox1.Items.Add("Bandung")
ListBox1.Items.Add("Bogor")
End Sub
'nadiahtami 2017230007
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'btn keluar
Dim pesan As String
pesan = MsgBox("Yakin ingin keluar?", vbYesNo, "Konfirmasi")
If pesan = vbYes Then
End
End If
End Sub
Private Sub kasus1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
agama()
jurusan()
programstudi()
kota()
End Sub
End Class
Public Class kasus2
' nadiahtami 2017230007
Sub bersih()
TextBox1.Clear()
TextBox2.Clear()
TextBox3.Clear()
TextBox4.Clear()
TextBox5.Clear()
TextBox6.Clear()
End Sub
Function hitung()
Dim harga, jumlah, total As Double
harga = TextBox4.Text
jumlah = TextBox5.Text
total = harga * jumlah
TextBox6.Text = total
Return total
End Function
Sub cekdata()
If TextBox1.Text = "" Then
MsgBox("Kode Barang Harus Diisi !!", vbOKOnly, "Konfirmasi")
TextBox1.Focus()
ElseIf TextBox2.Text = "" Then
MsgBox("Nama Barang Harus Diisi !!", vbOKOnly, "Konfirmasi")
TextBox2.Focus()
ElseIf TextBox3.Text = "" Then
MsgBox("Satuan Harus Diisi !!", vbOKOnly, "Konfirmasi")
TextBox3.Focus()
ElseIf TextBox4.Text = "" Then
MsgBox("Harga Satuan Harus Diisi !!", vbOKOnly, "Konfirmasi")
TextBox4.Focus()
ElseIf TextBox5.Text = "" Then
MsgBox("Jumlah Harus Diisi !!", vbOKOnly, "Konfirmasi")
TextBox5.Focus()
Else
Call hitung()
End If
End Sub
'nadiahtami 2017230007
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'btn clean
Call bersih()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
'btn keluar
Dim pesan As String
pesan = MsgBox("Yakin ingin keluar?", vbYesNo, "Konfirmasi")
If pesan = vbYes Then
End
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'btn hitung
Call cekdata()
End Sub
Private Sub kasus2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Call bersih()
End Sub
End Class
Public Class kasus3
'nadiahtami 2017230007
Sub bilanganganjil()
Dim ganjil As Integer
ListBox1.Items.Clear()
ganjil = 1
Do While ganjil <= 50
ListBox1.Items.Add(ganjil)
ganjil = ganjil + 2
Loop
End Sub
Sub bilangangenap()
Dim genap As Integer
ListBox1.Items.Clear()
genap = 0
Do While genap <= 50
ListBox1.Items.Add(genap)
genap = genap + 2
Loop
End Sub
Sub bilanganprima()
Dim prima, a, b, c As Integer
ListBox1.Items.Clear()
For a = 2 To 100
c = 0
For b = 2 To a
prima = a Mod b
If prima = 0 Then
c = c + 1
End If
Next b
If c <= 1 Then
ListBox1.Items.Add(a)
End If
Next a
End Sub
Sub proses(ByVal strganjil As String, ByRef strgenap As String, ByVal strprima As String)
If (ComboBox1.SelectedIndex.Equals(0)) Then
bilanganganjil()
ElseIf (ComboBox1.SelectedIndex.Equals(1)) Then
bilangangenap()
ElseIf (ComboBox1.SelectedIndex.Equals(2)) Then
bilanganprima()
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'btn input
Dim strganjil, strgenap, strprima As Integer
proses(strganjil, strgenap, strprima)
jumlah(TextBox1.Text, TextBox2.Text)
End Sub
Sub jumlah(ByRef bilangan1 As Integer, ByVal bilangan2 As Integer)
Dim hasil As Integer
hasil = bilangan1 + bilangan2
TextBox3.Text = hasil
End Sub
' nadiahtami 2017230007
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'btn keluar
Dim pesan As String
pesan = MsgBox("Yakin ingin keluar?", vbYesNo, "Konfirmasi")
If pesan = vbYes Then
End
End If
End Sub
End Class
Komentar
Posting Komentar