Pages

Selasa, 06 November 2012

Tugas 3 Pemrograman Visual

NAMA : NALENDRA PRIBADI
KELAS : TI 11 C
NIM      : 11.11.2514

          Modifikasi Program Penjualan Barang
  1. Saat form dijalankan : semua isian tidak aktif, tombol isi data dan tutup aktif, tombol clear tidak aktif. 
  2. Saat ditekan tombol isi data : kode barang, jumlah barang, cara beli, tombol clear, aktif, tombol isidata tidak aktif.
  3. Saat ditekan combol clear sama dengan saat form dijalankan.



Public Class Form1
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim a As Windows.Forms.Control

        For Each a In Me.Controls
            a.Enabled = False
            Button2.Enabled = True
            Button1.Enabled = True
        Next
       

        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) Handles cmbkode.SelectedIndexChanged
        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 “TAS”
                namabarang = “TAS”
                harga = 200000
            
            Case Else
                namabarang = “_”
                harga = 0

        End Select
        Txtnama.Text = namabarang
        Txtharga.Text = harga
        Txtharga.Text = Format(harga, “#,#”)
    End Sub

    Private Sub Txtjumlah_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Txtjumlah.TextChanged
        Dim total As Single

        Txttotal.Text = Val(Txtharga.Text) * Val(Txtjumlah.Text)
        Txtbayar.Text = Val(Txttotal.Text) – Val(Txtdiskon.Text)
        Txttotal.Text = Format(total, “#,#”)
    End Sub

    Private Sub Radiotunai_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Radiotunai.CheckedChanged
        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) Handles Radiokredit.CheckedChanged
        Txtdiskon.Text = 0
        Txtbayar.Text = Val(Txttotal.Text) – Val(Txtdiskon.Text)
    End Sub

    Private Sub Btclear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btclear.Click
        Dim a As Windows.Forms.Control

        For Each a In Me.Controls
            a.Enabled = False
            Button2.Enabled = True
            Button1.Enabled = True
        Next

        Txtbayar.Clear()
        Txtdiskon.Clear()
        Txtharga.Clear()
        Txtjumlah.Clear()
        Txtnama.Clear()
        Txttotal.Clear()
        Me.Radiotunai.Checked = False
        Me.Radiokredit.Checked = False
        cmbkode.Text = “”
    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 Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim a As Windows.Forms.Control

        For Each a In Me.Controls
            a.Enabled = True
            Button1.Enabled = False
        Next
    End Sub
End Class

Ini tampilan Saat from di jalankan semua isi tidak aktif , tombol isian tidak aktif, Tombol isi data dan Tutup aktif , tombol clear tidak aktif.

















Tampilan saat menekan tombol isi data : kode Barang,jumlah barang ,cara beli, Diskon, Total bayar, tombol clear,tutup aktif, tombol isi data tidak aktif.


















Pada saat menekan tombol clear sama dengan  saat from di jalankan.

















Tugas Puzzle

Jika ingin memulai acar game puzzle tekan start dan jika ingni berhenti mengacak tekan stop
















Dan jika kita berhasil akan menampilkan tampilan seperti dibawah ini













Jika ingin keluar klik close

berikut codingnya


Public Class Form1
    Dim smtr As String
    Private Sub Satu_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Satu.Click
        smtr = Satu.Text
        If (Dua.Text = "") Then
            Satu.Text = ""
            Dua.Text = smtr
        ElseIf (Empat.Text = "") Then
            Satu.Text = ""
            Empat.Text = smtr
        End If
        periksa()
    End Sub
    Private Sub Dua_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Dua.Click
        smtr = Dua.Text
        If (Satu.Text = "") Then
            Dua.Text = ""
            Satu.Text = smtr
        ElseIf (Tiga.Text = "") Then
            Dua.Text = ""
            Tiga.Text = smtr
        ElseIf (Lima.Text = "") Then
            Dua.Text = ""
            Lima.Text = smtr
        End If
        periksa()
    End Sub
    Private Sub Tiga_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Tiga.Click
        smtr = Tiga.Text
        If (Dua.Text = "") Then
            Tiga.Text = ""
            Dua.Text = smtr
        ElseIf (Enam.Text = "") Then
            Tiga.Text = ""
            Enam.Text = smtr
        End If
        periksa()
    End Sub
    Private Sub Empat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Empat.Click
        smtr = Empat.Text()
        If (Satu.Text = "") Then
            Empat.Text = ""
            Satu.Text = smtr
        ElseIf (Lima.Text = "") Then
            Empat.Text = ""
            Lima.Text = smtr
        ElseIf (Tujuh.Text = "") Then
            Empat.Text = ""
            Tujuh.Text = smtr
        End If
        periksa()
    End Sub
    Private Sub Lima_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Lima.Click
        smtr = Lima.Text
        If (Dua.Text = "") Then
            Lima.Text = ""
            Dua.Text = smtr
        ElseIf (Enam.Text = "") Then
            Lima.Text = ""
            Enam.Text = smtr
        ElseIf (Delapan.Text = "") Then
            Lima.Text = ""
            Delapan.Text = smtr
        ElseIf (Empat.Text = "") Then
            Lima.Text = ""
            Empat.Text = smtr
        End If
        periksa()
    End Sub
    Private Sub Enam_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Enam.Click
        smtr = Enam.Text
        If (Tiga.Text = "") Then
            Enam.Text = ""
            Tiga.Text = smtr
        ElseIf (Lima.Text = "") Then
            Enam.Text = ""
            Lima.Text = smtr
        ElseIf (Sembilan.Text = "") Then
            Enam.Text = ""
            Sembilan.Text = smtr
        End If
        periksa()
    End Sub
    Private Sub Tujuh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Tujuh.Click
        smtr = Tujuh.Text
        If (Empat.Text = "") Then
            Tujuh.Text = ""
            Empat.Text = smtr
        ElseIf (Delapan.Text = "") Then
            Tujuh.Text = ""
            Delapan.Text = smtr
        ElseIf (Sembilan.Text = "") Then
            Tujuh.Text = ""
            Sembilan.Text = smtr
        End If
        periksa()
    End Sub
    Private Sub Delapan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Delapan.Click
        smtr = Delapan.Text
        If (Lima.Text = "") Then
            Delapan.Text = ""
            Lima.Text = smtr
        ElseIf (Tujuh.Text = "") Then
            Delapan.Text = ""
            Tujuh.Text = smtr
        ElseIf (Sembilan.Text = "") Then
            Delapan.Text = ""
            Sembilan.Text = smtr
        End If
        periksa()
    End Sub

    Private Sub Sembilan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Sembilan.Click
        smtr = Sembilan.Text
        If (Enam.Text = "") Then
            Sembilan.Text = ""
            Enam.Text = smtr
        ElseIf (Delapan.Text = "") Then
            Sembilan.Text = ""
            Delapan.Text = smtr
        End If
        periksa()
    End Sub
    Private Sub periksa()
        If (Satu.Text = "1" And Dua.Text = "2" And Tiga.Text = "3" And Empat.Text = "4") Then
            If (Lima.Text = "5" And Enam.Text = "6" And Tujuh.Text = "7") Then
                If (Delapan.Text = "8") Then
                    MsgBox("Selamat Anda Berhasil Menyelesaikannya :D ")
                End If
            End If
        End If
    End Sub
    Private Sub Acak_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Acak.Click
        Timer1.Enabled = True
    End Sub

    Private Sub Henti_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Timer1.Stop()
        Satu.Text = "3"
        Dua.Text = "5"
        Tiga.Text = "1"
        Empat.Text = "7"
        Lima.Text = "6"
        Enam.Text = "8"
        Tujuh.Text = "2"
        Delapan.Text = "4"
        Sembilan.Text = ""
    End Sub
    Private Sub Keluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Keluar.Click
        If MsgBox("Anda yakin akan mengakhirinya ???", vbYesNo + vbQuestion + vbDefaultButton2, "keluar") = vbYes Then
            Me.Close()
        End If
    End Sub
    Dim a, b, c, d, f, g, h, i As Integer
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        a = (Rnd() * 7) + 1
        b = (Rnd() * 7) + 1
        c = (Rnd() * 7) + 1
        d = (Rnd() * 7) + 1
        f = (Rnd() * 7) + 1
        g = (Rnd() * 7) + 1
        h = (Rnd() * 7) + 1
        i = (Rnd() * 7) + 1

        Satu.Text = a
        Dua.Text = b
        Tiga.Text = c
        Empat.Text = d
        Lima.Text = f
        Enam.Text = g
        Tujuh.Text = h
        Delapan.Text = i
    End Sub


End Class



Tidak ada komentar:

Posting Komentar