Nama : Agung Bahtiar
Kelas:TI11E
NIM:11.11.2629
Modifikasi Program Penjualan
Modifikasi Program Penjualan Barang
- Saat form dijalankan : semua isian tidak aktif, tombol isi data dan tutup aktif, tombol clear tidak aktif.
- Saat ditekan tombol isi data : kode barang, jumlah barang, cara beli, tombol clear, aktif, tombol isidata tidak aktif.
- Saat ditekan combol clear sama dengan saat form dijalankan
tampilan sesudah dimodifikasi :
dan setelah diberi coding berikut :
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
btisi.Enabled = True
bttutup.Enabled = True
Next
cmbbokkodebarang.Items.Add("SPT")
cmbbokkodebarang.Items.Add("SND")
cmbbokkodebarang.Items.Add("TST")
cmbbokkodebarang.Items.Add("TOP")
cmbbokkodebarang.Items.Add("TAS")
End Sub
Private Sub cmbbokkodebarang_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbbokkodebarang.SelectedIndexChanged
Dim kdbarang, nmbarang As String
Dim harga As Single
kdbarang = cmbbokkodebarang.Text
Select Case kdbarang
Case "SPT"
nmbarang = "SEPATU"
harga = 200000
Case "SND"
nmbarang = "SENDAL"
harga = 100000
Case "TST"
nmbarang = "T-SHIRT"
harga = 150000
Case "TOP"
nmbarang = "TOPI"
harga = 50000
Case "TAS"
nmbarang = "TAS"
harga = 120000
Case Else
nmbarang = "_"
harga = 0
End Select
txtnamabrng.Text = nmbarang
txthrgbarang.Text = harga
txttotalharga.Text = Val(txthrgbarang.Text) * Val(txtjmlhbarang.Text)
txthrgbayar.Text = Val(txttotalharga.Text) - Val(txtdiscount.Text)
If btrdiotunai.Checked Then
txttotalharga.Text = Val(txthrgbarang.Text) * Val(txtjmlhbarang.Text)
txthrgbayar.Text = Val(txttotalharga.Text) - Val(txtdiscount.Text)
txtdiscount.Text = Val(txttotalharga.Text) * 10 / 100
Else
txtdiscount.Text = 0
txttotalharga.Text = Val(txthrgbarang.Text) * Val(txtjmlhbarang.Text)
txthrgbayar.Text = Val(txttotalharga.Text) - Val(txtdiscount.Text)
End If
End Sub
Private Sub txtjmlhbarang_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtjmlhbarang.TextChanged
txttotalharga.Text = Val(txthrgbarang.Text) * Val(txtjmlhbarang.Text)
txthrgbayar.Text = Val(txttotalharga.Text) - Val(txtdiscount.Text)
End Sub
Private Sub btrdiotunai_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btrdiotunai.CheckedChanged
txtdiscount.Text = Val(txttotalharga.Text) * 10 / 100
txthrgbayar.Text = Val(txttotalharga.Text) - Val(txtdiscount.Text)
End Sub
Private Sub btradiokredit_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btradiokredit.CheckedChanged
txtdiscount.Text = 0
txthrgbayar.Text = Val(txttotalharga.Text) - Val(txtdiscount.Text)
End Sub
Private Sub btclear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btclear.Click
txtnamabrng.Clear()
txthrgbarang.Clear()
txtjmlhbarang.Clear()
txttotalharga.Clear()
txtdiscount.Clear()
txthrgbayar.Clear()
Me.btrdiotunai.Checked = False
Me.btradiokredit.Checked = False
End Sub
Private Sub bttutup_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bttutup.Click
If MsgBox("apakah anda yakin", vbYesNo + vbQuestion + vbDefaultButton2, "program keluar") = vbYes Then
Me.Close()
End If
End Sub
Private Sub btisi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btisi.Click
Dim a As Windows.Forms.Control
For Each a In Me.Controls
a.Enabled = True
btisi.Enabled = False
Next
End Sub
End Class
maka tampilanya akan menjadi berikut :
Puzzle
untuk membuat program puzzle seperti berikut :
dan agar bisa dijalankan maka berikan coding programnya seperti berikut ini :Public Class Form1
Dim tampung As String
Dim jalan As Boolean = False
Dim acak As Integer
Private Sub btkeluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btkeluar.Click
Me.Close()
End Sub
Private Sub btacak_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btacak.Click
jalan = Not jalan
Timer1.Enabled = jalan
If jalan = False Then
btacak.Text = "ACAK"
Else
btacak.Text = "STOP"
End If
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim sementara As String
Do
jalan = Not jalan
sementara = btdua.Text
btdua.Text = btdelapan.Text
btdelapan.Text = btenam.Text
btenam.Text = btempat.Text
btempat.Text = btsatu.Text
btsatu.Text = bttiga.Text
bttiga.Text = bttujuh.Text
bttujuh.Text = btlima.Text
btlima.Text = btsembilan.Text
btsembilan.Text = sementara
Loop Until jalan = True
End Sub
Private Sub btdelapan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btdelapan.Click
If btsembilan.Text = "" Then
tampung = btlima.Text
btsembilan.Text = btdelapan.Text
btdelapan.Text = tampung
End If
If bttujuh.Text = "" Then
tampung = bttujuh.Text
bttujuh.Text = btdelapan.Text
btdelapan.Text = tampung
End If
If btlima.Text = "" Then
tampung = btlima.Text
btlima.Text = btdelapan.Text
btdelapan.Text = tampung
End If
End Sub
Private Sub btsembilan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btsembilan.Click
If btenam.Text = "" Then
tampung = btenam.Text
btenam.Text = btsembilan.Text
btsembilan.Text = tampung
End If
If btdelapan.Text = "" Then
tampung = btdelapan.Text
btdelapan.Text = btsembilan.Text
btsembilan.Text = tampung
End If
If btsatu.Text = "1" And btdua.Text = "2" And bttiga.Text = "3" And btempat.Text = "4" And
btlima.Text = "5" And btenam.Text = "6" And bttujuh.Text = "7" And btdelapan.Text = "8" And btsembilan.Text = "" Then
MsgBox("Selamat anda berhasil menyelesaikan tantangan game puzzle silahkan coba lagi..!" + vbInformation + vbOKOnly, "")
End If
End Sub
Private Sub btenam_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btenam.Click
If btsembilan.Text = "" Then
tampung = btsembilan.Text
btsembilan.Text = btenam.Text
btenam.Text = tampung
End If
If bttiga.Text = "" Then
tampung = bttiga.Text
bttiga.Text = btenam.Text
btenam.Text = tampung
End If
If btlima.Text = "" Then
tampung = btlima.Text
btlima.Text = btenam.Text
btenam.Text = tampung
End If
End Sub
Private Sub btlima_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btlima.Click
If btenam.Text = "" Then
tampung = btenam.Text
btenam.Text = btlima.Text
btlima.Text = tampung
End If
If btdelapan.Text = "" Then
tampung = btdelapan.Text
btdelapan.Text = btlima.Text
btlima.Text = tampung
End If
If btempat.Text = "" Then
tampung = btempat.Text
btempat.Text = btlima.Text
btlima.Text = tampung
End If
If btdua.Text = "" Then
tampung = btdua.Text
btdua.Text = btlima.Text
btlima.Text = tampung
End If
End Sub
Private Sub btempat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btempat.Click
If btlima.Text = "" Then
tampung = btlima.Text
btlima.Text = btempat.Text
btempat.Text = tampung
End If
If bttujuh.Text = "" Then
tampung = bttujuh.Text
bttujuh.Text = btempat.Text
btempat.Text = tampung
End If
If btsatu.Text = "" Then
tampung = btsatu.Text
btsatu.Text = btempat.Text
btempat.Text = tampung
End If
End Sub
Private Sub bttiga_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bttiga.Click
If btenam.Text = "" Then
tampung = btenam.Text
btenam.Text = bttiga.Text
bttiga.Text = tampung
End If
If btdua.Text = "" Then
tampung = btdua.Text
btdua.Text = bttiga.Text
bttiga.Text = tampung
End If
End Sub
Private Sub btdua_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btdua.Click
If bttiga.Text = "" Then
tampung = bttiga.Text
bttiga.Text = btdua.Text
btdua.Text = tampung
End If
If btlima.Text = "" Then
tampung = btlima.Text
btlima.Text = btdua.Text
btdua.Text = tampung
End If
If btsatu.Text = "" Then
tampung = btsatu.Text
btsatu.Text = btdua.Text
End If
End Sub
Private Sub btsatu_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btsatu.Click
If btdua.Text = "" Then
tampung = btdua.Text
btdua.Text = btsatu.Text
btsatu.Text = tampung
End If
If btempat.Text = "" Then
tampung = btempat.Text
btempat.Text = btsatu.Text
btsatu.Text = tampung
End If
End Sub
End Class
setelah itu maka akan jadi puzzelnya seperti tampilan berikut ini, dan bisa di maikan
0 komentar:
Posting Komentar