Archive for 2012-10-21

Tugas 3 Pemrograman Visual

Modifikasi Program Penjualan Barang
1.    Modifikasi form menjadi seperti ini

2.    Lalu tambahkan script yang bercetak tebal (BOLD)


Public Class Form1
 
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        cmbkode.Items.Add("SPT")
        cmbkode.Items.Add("SND")
        cmbkode.Items.Add("TST")
        cmbkode.Items.Add("TOP")
        cmbkode.Items.Add("TAS")
    End Sub

    Private Sub cmbkode_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Dim kdbarang, namabarang As String
        Dim harga As Single
        kdbarang = cmbkode.Text

        Select Case kdbarang
            Case "SPT"
                namabarang = "sepatu"
                harga = "200000"
            Case "SND"
                namabarang = "sandal"
                harga = "100000"
            Case "TST"
                namabarang = "T-Shirt"
                harga = "150000"
            Case "TOP"
                namabarang = "Topi"
                harga = "50000"
            Case Else
                namabarang = "Tas"
                harga = "90000"
        End Select
        txtnama.Text = namabarang
        txtharga.Text = harga
    End Sub

    Private Sub txtjumlah_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
        txttotal.Text = Val(txtharga.Text) * Val(txtjumlah.Text)
        txtbayar.Text = Val(txttotal.Text) - Val(txtdiskon.Text)
    End Sub

    Private Sub radiotunai_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
        txtdiskon.Text = Val(txttotal.Text) * 10 / 100
        txtbayar.Text = Val(txttotal.Text) - Val(txtdiskon.Text)
    End Sub

    Private Sub radiokredit_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
        txtdiskon.Text = 0
        txtbayar.Text = Val(txttotal.Text) - Val(txtdiskon.Text)
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        txtbayar.Clear()
        txtdiskon.Clear()
        txtharga.Clear()
        txtjumlah.Clear()
        txtnama.Clear()
        txttotal.Clear()
        Me.radiotunai.Checked = False
        Me.radiokredit.Checked = False
        cmbkode.Text = ""
        GroupBox1.Enabled = False
        Button1.Enabled = True


    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Me.Close()
    End Sub


    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        cmbkode.Items.Add("SPT")
        cmbkode.Items.Add("SND")
        cmbkode.Items.Add("TST")
        cmbkode.Items.Add("TOP")
        cmbkode.Items.Add("TAS")
        GroupBox1.Enabled = False

    End Sub

    Private Sub GroupBox1_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GroupBox1.Enter
        cmbkode.Items.Add("SPT")
        cmbkode.Items.Add("SND")
        cmbkode.Items.Add("TST")
        cmbkode.Items.Add("TOP")
        cmbkode.Items.Add("TAS")
        GroupBox1.Enabled = False

    End Sub


End Class



Puzzle
1.    Buat Form sebagai berikut

2.    Isikan Script berikut ini pada form

Dim control As Windows.Forms.Control
        For Each control In Me.Controls
            If control.GetType.Name = "Button" Then
                Dim rndnumber As Random
                Dim number As Integer
                rndnumber = New Random
                number = rndnumber.Next(1, 9)
                control.Text = number

                If Button2.Text = Button1.Text Then
                    Do
                        number = rndnumber.Next(1, 9)
                        Button2.Text = number
                    Loop Until Button2.Text <> Button1.Text
                End If

                If Button3.Text = Button2.Text Or Button3.Text = Button1.Text Then
                    Do
                        number = rndnumber.Next(1, 9)
                        Button3.Text = number
                    Loop Until Button3.Text <> Button2.Text And Button3.Text <> Button1.Text
                End If

                If Button4.Text = Button3.Text Or Button4.Text = Button2.Text Or Button4.Text = Button1.Text Then
                    Do
                        number = rndnumber.Next(1, 9)
                        Button4.Text = number
                    Loop Until Button4.Text <> Button3.Text And Button4.Text <> Button2.Text And Button4.Text <> Button1.Text
                End If

                If Button4.Text = Button3.Text Or Button4.Text = Button2.Text Or Button4.Text = Button1.Text Then
                    Do
                        number = rndnumber.Next(1, 9)
                        Button4.Text = number
                    Loop Until Button4.Text <> Button3.Text And Button4.Text <> Button2.Text And Button4.Text <> Button1.Text
                End If

                If Button5.Text = Button4.Text Or Button5.Text = Button3.Text Or Button5.Text = Button2.Text Or Button5.Text = Button1.Text Then
                    Do
                        number = rndnumber.Next(1, 9)
                        Button5.Text = number
                    Loop Until Button5.Text <> Button4.Text And Button5.Text <> Button3.Text And Button5.Text <> Button2.Text And Button5.Text <> Button1.Text
                End If

                If Button6.Text = Button5.Text Or Button6.Text = Button4.Text Or Button6.Text = Button3.Text Or Button6.Text = Button2.Text Or Button6.Text = Button1.Text Then
                    Do
                        number = rndnumber.Next(1, 9)
                        Button6.Text = number
                    Loop Until Button6.Text <> Button5.Text And Button6.Text <> Button3.Text And Button6.Text <> Button2.Text And Button6.Text <> Button1.Text
                End If

                If Button7.Text = Button6.Text Or Button7.Text = Button5.Text Or Button7.Text = Button4.Text Or Button7.Text = Button3.Text Or Button7.Text = Button2.Text Or Button7.Text = Button1.Text Then
                    Do
                        number = rndnumber.Next(1, 9)
                        Button7.Text = number
                    Loop Until Button7.Text <> Button6.Text And Button7.Text <> Button5.Text And Button7.Text <> Button4.Text And Button7.Text <> Button3.Text And Button7.Text <> Button2.Text And Button7.Text <> Button1.Text
                End If

                If Button8.Text = Button7.Text Or Button8.Text = Button6.Text Or Button8.Text = Button5.Text Or Button8.Text = Button4.Text Or Button8.Text = Button3.Text Or Button8.Text = Button2.Text Or Button8.Text = Button1.Text Then
                    Do
                        number = rndnumber.Next(1, 9)
                        Button8.Text = number
                    Loop Until Button8.Text <> Button7.Text And Button8.Text <> Button6.Text And Button8.Text <> Button5.Text And Button8.Text <> Button4.Text And Button8.Text <> Button3.Text And Button8.Text <> Button2.Text And Button8.Text <> Button1.Text
                End If
            End If
            Button9.Text = ""
        Next
1.    Dan skrip dibawah ini pada  tombol

a.       Button1
If Button2.Text = "" Then
            Button2.Text = Button1.Text
            Button1.Text = ""
        ElseIf Button4.Text = "" Then
            Button4.Text = Button1.Text
            Button1.Text = ""
        End If
        If Button1.Text = "1" And Button2.Text = "2" And Button3.Text = "3" And Button4.Text = "4" And Button5.Text = "5" And Button6.Text = "6" And Button7.Text = "7" And Button8.Text = "8" And Button9.Text = "" Then
            MsgBox("Selamat Anda Menang")
        End If
b.  Button2
If Button1.Text = "" Then
            Button1.Text = Button2.Text
            Button2.Text = ""
        ElseIf Button3.Text = "" Then
            Button3.Text = Button2.Text
            Button2.Text = ""
        ElseIf Button5.Text = "" Then
            Button5.Text = Button2.Text
            Button2.Text = ""
        End If
        If Button1.Text = "1" And Button2.Text = "2" And Button3.Text = "3" And Button4.Text = "4" And Button5.Text = "5" And Button6.Text = "6" And Button7.Text = "7" And Button8.Text = "8" And Button9.Text = "" Then
            MsgBox("Selamat Anda Menang")
        End If
c.  Button3
If Button2.Text = "" Then
            Button2.Text = Button3.Text
            Button3.Text = ""
        ElseIf Button6.Text = "" Then
            Button6.Text = Button3.Text
            Button3.Text = ""
        End If
        If Button1.Text = "1" And Button2.Text = "2" And Button3.Text = "3" And Button4.Text = "4" And Button5.Text = "5" And Button6.Text = "6" And Button7.Text = "7" And Button8.Text = "8" And Button9.Text = "" Then
            MsgBox("Selamat Anda Menang")
        End If
d.  Button4
If Button1.Text = "" Then
            Button1.Text = Button4.Text
            Button4.Text = ""
        ElseIf Button7.Text = "" Then
            Button7.Text = Button4.Text
            Button4.Text = ""
        ElseIf Button5.Text = "" Then
            Button5.Text = Button4.Text
            Button4.Text = ""
        End If
        If Button1.Text = "1" And Button2.Text = "2" And Button3.Text = "3" And Button4.Text = "4" And Button5.Text = "5" And Button6.Text = "6" And Button7.Text = "7" And Button8.Text = "8" And Button9.Text = "" Then
            MsgBox("Selamat Anda Menang")
        End If
e.  Button5
If Button2.Text = "" Then
            Button2.Text = Button5.Text
            Button5.Text = ""
        ElseIf Button4.Text = "" Then
            Button4.Text = Button5.Text
            Button5.Text = ""
        ElseIf Button6.Text = "" Then
            Button6.Text = Button5.Text
            Button5.Text = ""
        ElseIf Button8.Text = "" Then
            Button8.Text = Button5.Text
            Button5.Text = ""
        End If
        If Button1.Text = "1" And Button2.Text = "2" And Button3.Text = "3" And Button4.Text = "4" And Button5.Text = "5" And Button6.Text = "6" And Button7.Text = "7" And Button8.Text = "8" And Button9.Text = "" Then
            MsgBox("Selamat Anda Menang")
        End If
f.  Button6
If Button9.Text = "" Then
            Button9.Text = Button6.Text
            Button6.Text = ""
        ElseIf Button3.Text = "" Then
            Button3.Text = Button6.Text
            Button6.Text = ""
        ElseIf Button5.Text = "" Then
            Button5.Text = Button6.Text
            Button6.Text = ""
        End If
        If Button1.Text = "1" And Button2.Text = "2" And Button3.Text = "3" And Button4.Text = "4" And Button5.Text = "5" And Button6.Text = "6" And Button7.Text = "7" And Button8.Text = "8" And Button9.Text = "" Then
            MsgBox("Selamat Anda Menang")
        End If
g.  Button7
If Button4.Text = "" Then
            Button4.Text = Button7.Text
            Button7.Text = ""
        ElseIf Button8.Text = "" Then
            Button8.Text = Button7.Text
            Button7.Text = ""
        End If
        If Button1.Text = "1" And Button2.Text = "2" And Button3.Text = "3" And Button4.Text = "4" And Button5.Text = "5" And Button6.Text = "6" And Button7.Text = "7" And Button8.Text = "8" And Button9.Text = "" Then
            MsgBox("Selamat Anda Menang")
        End If
h.  Button8
If Button7.Text = "" Then
            Button7.Text = Button8.Text
            Button8.Text = ""
        ElseIf Button9.Text = "" Then
            Button9.Text = Button8.Text
            Button8.Text = ""
        ElseIf Button5.Text = "" Then
            Button5.Text = Button8.Text
            Button8.Text = ""
        End If
        If Button1.Text = "1" And Button2.Text = "2" And Button3.Text = "3" And Button4.Text = "4" And Button5.Text = "5" And Button6.Text = "6" And Button7.Text = "7" And Button8.Text = "8" And Button9.Text = "" Then
            MsgBox("Selamat Anda Menang")
        End If
i.  Button9
If Button6.Text = "" Then
            Button6.Text = Button9.Text
            Button9.Text = ""
        ElseIf Button8.Text = "" Then
            Button8.Text = Button9.Text
            Button9.Text = ""
        End If
        If Button1.Text = "1" And Button2.Text = "2" And Button3.Text = "3" And Button4.Text = "4" And Button5.Text = "5" And Button6.Text = "6" And Button7.Text = "7" And Button8.Text = "8" And Button9.Text = "" Then
            MsgBox("Selamat Anda Menang")
        End If

Sabtu, 27 Oktober 2012
Posted by Yusuf Suprianto

- Copyright © QIEBAE -Metrominimalist- Powered by Blogger - Designed by Johanes Djogan -