Ads 468x60px

Sabtu, 27 Oktober 2012

TUGAS 3

MEMODIFIKASI PROGRAM PENJUALAN


1.

a) Saat form dijalankan : semua isian tidak aktif, tombol isidata dan tutup aktif, tombol clear tidak aktif
b) Saat ditekan tombol isi data : kodebarang, jumlahbarang, cara beli, tombol clear, aktif, tombol isidata tidak aktif
c) Saat ditekan combol clear sama dengan saat form dijalankan.

jawab:
 1. Buka program yang kmarin dibuat



tambahkan button lalu rename agar manjadi seperti ini:



berikut ini adalah listing programnya :



listing pada form:

Dim control As Windows.Forms.Control
        For Each control In Me.Controls
            control.Enabled = False
            Button3.Enabled = True
            Button2.Enabled = True
        Next
        CmbKodbar.Items.Add("SPT")
        CmbKodbar.Items.Add("SND")
        CmbKodbar.Items.Add("TST")
        CmbKodbar.Items.Add("CLN")
        CmbKodbar.Items.Add("TAS")

3.  kemudian edit listing  pada button clear menjadi seperti ini;
               
      Dim control As Windows.Forms.Control
        For Each control In Me.Controls
            control.Enabled = False
            Button3.Enabled = True
            Button2.Enabled = True
        Next

        TxtNambar.Clear()
        TxtHarbar.Clear()
        TxtJumbar.Clear()
        TxtTotHarg.Clear()
        TxtDiskon.Clear()
        TxtTotBayr.Clear()
        Me.RadioButton1.Checked = False
        Me.RadioButton2.Checked = False
        CmbKodbar.Text = ""


4.     button isi data   diisi listing seperti ini :

                Dim control As Windows.Forms.Control
        For Each control In Me.Controls
            control.Enabled = True
            Button3.Enabled = False
        Next
5.      Lalu di Run,di debug pencet F5
         Dan hasilnya seperti berikut ini;



lihat screenshot diatas, semua button tidak aktiv kecuali button isi data dan button tutup

6. klik button isi data dan hasilnya jadi seperti ini:

7.selanjutnya kita coba isi datanya maka akan nampak seperti gambar dibawah:


apabila kita menekan tombol clear hasilnya akan kosong seperti semula,kosong adalah kosong isi adalah isi



berikut ini adalah listing dari seluruh button,toolbox
Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim control As Windows.Forms.Control
        For Each control In Me.Controls
            control.Enabled = False
            Button3.Enabled = True
            Button2.Enabled = True
        Next
        CmbKodbar.Items.Add("SPT")
        CmbKodbar.Items.Add("SND")
        CmbKodbar.Items.Add("TST")
        CmbKodbar.Items.Add("CLN")
        CmbKodbar.Items.Add("TAS")

    End Sub

    Private Sub CmbKodbar_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmbKodbar.SelectedIndexChanged
        Dim Kodebarang, Namabarang As String
        Dim Harga As Single
        Kodebarang = CmbKodbar.Text

        Select Case Kodebarang
            Case "SPT"
                Namabarang = "Sepatu"
                Harga = 100000
            Case "SND"
                Namabarang = "Sendal"
                Harga = 25000
            Case "TST"
                Namabarang = "T-Shirt"
                Harga = 30000
            Case "CLN"
                Namabarang = "Celana"
                Harga = 150000
            Case "TAS"
                Namabarang = "TAS"
                Harga = 90000

            Case Else
                Namabarang = "-"
                Harga = 0

        End Select
        TxtNambar.Text = Namabarang
        TxtHarbar.Text = Harga

    End Sub

    Private Sub TxtJumbar_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TxtJumbar.TextChanged
        TxtTotHarg.Text = Val(TxtHarbar.Text) * Val(TxtJumbar.Text)
        TxtTotBayr.Text = Val(TxtTotHarg.Text) - Val(TxtDiskon.Text)
    End Sub

    Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
        TxtDiskon.Text = Val(TxtTotHarg.Text) * 10 / 100
        TxtTotBayr.Text = Val(TxtTotHarg.Text) - Val(TxtDiskon.Text)
    End Sub

    Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged
        TxtDiskon.Text = 0
        TxtTotBayr.Text = Val(TxtTotHarg.Text) - Val(TxtDiskon.Text)
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim control As Windows.Forms.Control
        For Each control In Me.Controls
            control.Enabled = False
            Button3.Enabled = True
            Button2.Enabled = True
        Next

        TxtNambar.Clear()
        TxtHarbar.Clear()
        TxtJumbar.Clear()
        TxtTotHarg.Clear()
        TxtDiskon.Clear()
        TxtTotBayr.Clear()
        Me.RadioButton1.Checked = False
        Me.RadioButton2.Checked = False
        CmbKodbar.Text = ""


    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        If MsgBox("Apakah ente ingin keluar ?",
                  vbYesNo + vbQuestion + vbDefaultButton2, "Keluar") = vbYes Then
        End If
        Me.Close()

    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Dim control As Windows.Forms.Control
        For Each control In Me.Controls
            control.Enabled = True
            Button3.Enabled = False
        Next
    End Sub

End Class




Soal 2
Buatlah permainan puzzle sederhana 
Membuat Puzzle Sederhana

1.buatlah desain form dengan ketentuan 9 tombol button dan rename button1 menjadi "1" button 2 menjadi "2" dan seterusnya tapi tanpa tanda petik,form terserah mau dikasih gambar apa tidak,contohnya seperti buatan saya seperti screenshot dibawah ini:

masukan listing coding programnya seperti di bawah ini
Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        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
    End Sub

    Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
        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 Telah Berhasil")
        End If
    End Sub

    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
        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 Telah Berhasil")
        End If
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        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 Telah Berhasil")
        End If
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        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 Telah Berhasil")
        End If
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        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 Telah Berhasil")
        End If
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        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 Telah Berhasil")
        End If
    End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        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 Telah Berhasil")
        End If
    End Sub

    Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
        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 Telah Berhasil")
        End If
    End Sub

    Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
        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 Telah Berhasil")
        End If

    End Sub
End Class

==============================================
beberapa screenshoot dari puzzle setelah di run




Tidak ada komentar:

Posting Komentar