Procedure dan Function Visual Lanjutan
Awesome Image

Assalamualaikum wr.wb

Apa kabar teman teman semua masi sehat kan, Pada pertemuan kali ini saya masih akan membahasa Materi "Procedure dan Function" dengan Program yang berbeda Yuk langsung simak dibawah ini :
 
Tugas Praktikum 5 
 
Kasus 1 Procedure dan Function
Source Code :
Public Class kasus1
    'Naufal Farisi Zamzam
    '2017230092
 
    Private Sub kasus1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.Text = "Naufal Farisi Zamzam"
 
    End Sub
 
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim psn As String
        psn = MsgBox("Yakin Mau Cabut?", vbYesNo, "naufalfz.my.id")
        If psn = vbYes Then
            End
        End If
    End Sub
 
    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        Me.ComboBox1.Items.Add("Islam")
        Me.ComboBox1.Items.Add("Kristen")
        Me.ComboBox1.Items.Add("Hindu")
        Me.ComboBox1.Items.Add("Budha")
        Me.ComboBox1.Items.Add("Atheis")
    End Sub
 
    Private Sub ComboBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox2.SelectedIndexChanged
        Me.ComboBox2.Items.Add("Teknik Nuklir")
        Me.ComboBox2.Items.Add("Teknik Lingkungan")
        Me.ComboBox2.Items.Add("Teknik Informatika")
    End Sub
 
    Private Sub ComboBox3_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox3.SelectedIndexChanged
        Me.ComboBox3.Items.Add("S1")
        Me.ComboBox3.Items.Add("S2")
        Me.ComboBox3.Items.Add("S3")
    End Sub
 
    Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
        Me.ListBox1.Items.Add("Jakarta")
        Me.ListBox1.Items.Add("Cirebon")
        Me.ListBox1.Items.Add("Jogja")
        Me.ListBox1.Items.Add("Bandung")
        Me.ListBox1.BackColor = Color.Red
    End Sub
End Class
 
Kasus 2 Procedure dan Function
Source Code :
Public Class Kasus2
    '2017230092
    'Naufal Farisi Zamzam
    Sub Clean()
        TextBox1.Clear()
        TextBox2.Clear()
        TextBox3.Clear()
        TextBox4.Clear()
        TextBox5.Clear()
        TextBox6.Clear()
    End Sub
 
    Private Function hitung()
        Dim amount, priceamount, total As Double
        amount = TextBox5.Text
        priceamount = TextBox4.Text
        total = amount * priceamount
        TextBox6.Text = total
        Return total
    End Function
 
    Sub CheckEmptyData()
        If TextBox1.Text = "" Then
            MessageBox.Show("Item Code Must be Filled !!", "Confrim", MessageBoxButtons.OK, MessageBoxIcon.Warning)
            TextBox1.Focus()
        ElseIf TextBox2.Text = "" Then
            MessageBox.Show("Item Name Must be Filled !!", "Confrim", MessageBoxButtons.OK, MessageBoxIcon.Warning)
            TextBox3.Focus()
        ElseIf TextBox3.Text = "" Then
            MessageBox.Show("Unit Must Be Filled !!", "Confirm", MessageBoxButtons.OK, MessageBoxIcon.Warning)
            TextBox3.Focus()
        ElseIf TextBox5.Text = "" Then
            MessageBox.Show("Amount Must Be Filled !!", "Confirm", MessageBoxButtons.OK, MessageBoxIcon.Warning)
            TextBox5.Focus()
        ElseIf TextBox4.Text = "" Then
            MessageBox.Show("Unit Price Must Be Filled !!", "Confirm", MessageBoxButtons.OK, MessageBoxIcon.Warning)
            TextBox4.Focus()
        Else
            Call hitung()
        End If
 
    End Sub
 
    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Dim psn As String
        psn = MsgBox("Yakin Mau Cabut?", vbYesNo, "naufalfz.my.id")
        If psn = vbYes Then
            End
        End If
    End Sub
Private Sub Kasus2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.Text = "Naufal Farisi Zamzam"
        Call Clean()
    End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Call Clean()
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Call CheckEmptyData()
    End Sub
End Class

 Kasus 2 Procedure dan Function

Source Code : 

Public Class kasus3
    '2017230092
    'Naufal Farisi Zamzam
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Me.Text = "Naufal Farisi Zamzam"
        Dim strganjil, strgenap, strprima, strfibo As Integer
        Proses(strganjil, strgenap, strprima, strfibo)
        ShowSum(TextBox1.Text, TextBox2.Text)
    End Sub
 
    Sub ShowSum(ByRef intnum1 As Integer, ByVal intnum2 As Integer)
        Dim intsum As Integer
        intsum = intnum1 + intnum2
        TextBox3.Text = intsum
    End Sub
 
    Sub bilganjil()
        Dim ganjil As Integer
        ListBox1.Items.Clear()
        ganjil = 1
        Do While ganjil <= 20
            ListBox1.Items.Add(ganjil)
            ganjil = ganjil + 2
        Loop
    End Sub
 
    Sub bilgenap()
        Dim genap As Integer
        ListBox1.Items.Clear()
        genap = 0
        Do While genap <= 20
            ListBox1.Items.Add(genap)
            genap = genap + 2
        Loop
    End Sub
 
    Sub bilprima()
        Dim prima, x, y, z As Integer
        ListBox1.Items.Clear()
        For x = 2 To 100
            z = 0
            For y = 2 To x
                prima = x Mod y
                If prima = 0 Then
                    z = z + 1
 
                End If
            Next y
            If z <= 1 Then
                ListBox1.Items.Add(x)
 
            End If
        Next x
    End Sub
 
    Sub bilfibo()
        ListBox1.Items.Clear()
        Dim a As Integer = 0
        Dim b As Integer = 1
        Dim fib As Integer = 0
        ListBox1.Items.Add("1")
        Do
            fib = a + b
            a = b
            b = fib
            ListBox1.Items.Add(fib.ToString)
        Loop While fib <= 100
    End Sub
 
    Sub proses(ByVal strganjil As String, ByRef strgenap As String, ByVal strprima As String, ByVal strfibo As String)
        If (ComboBox1.SelectedIndex.Equals(0)) Then
            bilganjil()
        ElseIf (ComboBox1.SelectedIndex.Equals(1)) Then
 
 
            bilgenap()
        ElseIf (ComboBox1.SelectedIndex.Equals(2)) Then
 
 
            bilprima()
        ElseIf (ComboBox1.SelectedIndex.Equals(3)) Then
 
 
            bilfibo()
        End If
 
    End Sub
 
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim psn As String
        psn = MsgBox("Yakin Mau Cabut?", vbYesNo, "naufalfz.my.id")
        If psn = vbYes Then
            End
        End If
    End Sub
End Class

 

Sekian untuk Kasus kali ini saya harap teman teman mengerti dan paham jika ada pertanyaan, saran dan masukan silahkan contact saya di bawah ini.
Oh iya untuk review materi sebelumnya bisa cek di link berikut :

Wassalamualaikum wr.wb