MODIFIKASI PROGRAM PENJUALAN
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
1. Tambahkan 1 Button untuk program yang kemarin,
Dan edit button tadi
menjadi isi data
Seperti dibawah ini;
2. Selanjutnya kita isi
listing programnya;
Coding pada form di
tambah seperti dibawah ini;
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. Selanjutnya edit pada button clear sehinga
menjadi seperti dibawah 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. Yang terakhir isi button ‘’isi data”;
Dim control As Windows.Forms.Control
For Each control In Me.Controls
control.Enabled = True
Button3.Enabled = False
Next
5. Lalu di Run
Dan hasilnya seperti berikut ini;
6. Klik button Isi data, dan hasilnya seperti
dibawah ini;
Setelah di isi
Jika di clear
seperti pada waktu di Run pertama kali
yaitu seperti dibawah ini:
Untuk listing program keseluruhan sebagai berikut:
Listing Program
Penjulan Setelah di modifikasi
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 anda 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
Untuk Programnya silahkan download dibawah ini..
====== TUGAS MEMBUAT GAME PUZZLE======
Dibawah ini merupakan game puzzle sederhana.... untuk lebih jelasnya silahkan baca berikut ini.....
1.
Desain
Game puzzle seperti dibawah ini dengan menggunakan tool Button sebanyak 9
Button.
Pada propertis tiap2 button ganti seperti
dibawah ini:
Ganti
text button1 dengan 1 dan name
button1 dengan satu
Ganti
text button1 dengan 2 dan name
button1 dengan dua
Ganti
text button1 dengan 3 dan name
button1 dengan tiga
Ganti
text button1 dengan 4 dan name
button1 dengan empat
Ganti
text button1 dengan 5 dan name
button1 dengan lima
Ganti
text button1 dengan 6 dan name
button1 dengan enam
Ganti
text button1 dengan 7 dan name
button1 dengan tujuh
Ganti
text button1 dengan 8 dan name
button1 dengan delapan
Ganti
text button1 dengan 9 dan name
button1 dengan kosong
2.
Kemudian
masukan coding pada Form1 dengan cara Form1 di klik 2 kali
Adapun codingnya yaitu seperti dibawah ini:
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
dua.Text = satu.Text Then
Do
number =
rndnumber.Next(1, 9)
dua.Text = number
Loop
Until dua.Text <> satu.Text
End
If
If tiga.Text =
dua.Text Or tiga.Text = satu.Text Then
Do
number =
rndnumber.Next(1, 9)
tiga.Text = number
Loop
Until tiga.Text <> dua.Text And tiga.Text <> satu.Text
End
If
If
empat.Text = tiga.Text Or empat.Text = dua.Text
Or empat.Text = satu.Text Then
Do
number =
rndnumber.Next(1, 9)
empat.Text = number
Loop Until empat.Text <> tiga.Text And empat.Text <> dua.Text And empat.Text <> satu.Text
End
If
If
empat.Text = tiga.Text Or empat.Text = dua.Text
Or empat.Text = satu.Text Then
Do
number =
rndnumber.Next(1, 9)
empat.Text = number
Loop
Until empat.Text <> tiga.Text And empat.Text <> dua.Text And empat.Text <> satu.Text
End
If
If
lima.Text = empat.Text Or lima.Text = tiga.Text
Or lima.Text = dua.Text Or lima.Text = satu.Text Then
Do
number =
rndnumber.Next(1, 9)
lima.Text = number
Loop
Until lima.Text <> empat.Text And lima.Text <> tiga.Text And lima.Text <> dua.Text And lima.Text <> satu.Text
End
If
If
enam.Text = lima.Text Or enam.Text = empat.Text
Or enam.Text = tiga.Text Or enam.Text = dua.Text Or
enam.Text = satu.Text Then
Do
number =
rndnumber.Next(1, 9)
enam.Text = number
Loop
Until enam.Text <> lima.Text And enam.Text <> tiga.Text And enam.Text <> dua.Text And enam.Text <> satu.Text
End
If
If
tujuh.Text = enam.Text Or tujuh.Text =
lima.Text Or tujuh.Text = empat.Text Or tujuh.Text = tiga.Text Or
tujuh.Text = dua.Text Or tujuh.Text = satu.Text
Then
Do
number = rndnumber.Next(1, 9)
tujuh.Text = number
Loop
Until tujuh.Text <> enam.Text And tujuh.Text <> lima.Text And tujuh.Text <> empat.Text And tujuh.Text <> tiga.Text And tujuh.Text <> dua.Text And tujuh.Text <> satu.Text
End
If
If
delapan.Text = tujuh.Text Or delapan.Text =
enam.Text Or delapan.Text = lima.Text Or delapan.Text = empat.Text Or
delapan.Text = tiga.Text Or delapan.Text =
dua.Text Or delapan.Text = satu.Text Then
Do
number =
rndnumber.Next(1, 9)
delapan.Text = number
Loop
Until delapan.Text <> tujuh.Text And delapan.Text <> enam.Text And delapan.Text <> lima.Text And delapan.Text <> empat.Text And delapan.Text <> tiga.Text And delapan.Text <> dua.Text And delapan.Text <> satu.Text
End
If
End
If
kosong.Text = ""
Next
End Sub
3. Setelah
itu masukan coding untuk tiap-tiap Button, kita mulai dari
BUTTON 1;
If dua.Text = "" Then
dua.Text = satu.Text
satu.Text = ""
ElseIf
empat.Text = "" Then
empat.Text = satu.Text
satu.Text = ""
End If
If
satu.Text = "1" And dua.Text = "2"
And tiga.Text = "3"
And empat.Text = "4"
And lima.Text = "5"
And enam.Text = "6"
And tujuh.Text = "7"
And delapan.Text = "8"
And kosong.Text = ""
Then
MsgBox("Selamat
Anda Berhasil")
End If
End Sub
BUTTON
2;
If satu.Text = ""
Then
satu.Text = dua.Text
dua.Text = ""
ElseIf
tiga.Text = "" Then
tiga.Text = dua.Text
dua.Text = ""
ElseIf
lima.Text = "" Then
lima.Text = dua.Text
dua.Text = ""
End If
If
satu.Text = "1" And dua.Text = "2"
And tiga.Text = "3"
And empat.Text = "4"
And lima.Text = "5"
And enam.Text = "6"
And tujuh.Text = "7"
And delapan.Text = "8"
And kosong.Text = ""
Then
MsgBox("Selamat
Anda Berhasil")
End If
BUTTON
3;
If dua.Text = "" Then
dua.Text = tiga.Text
tiga.Text = ""
ElseIf
enam.Text = "" Then
enam.Text = tiga.Text
tiga.Text = ""
End If
If
satu.Text = "1" And dua.Text = "2"
And tiga.Text = "3"
And empat.Text = "4"
And lima.Text = "5"
And enam.Text = "6"
And tujuh.Text = "7"
And delapan.Text = "8"
And kosong.Text = ""
Then
MsgBox("Selamat
Anda Berhasil")
End If
BUTTON
4;
If satu.Text = "" Then
satu.Text = empat.Text
empat.Text = ""
ElseIf
tujuh.Text = "" Then
tujuh.Text = empat.Text
empat.Text = ""
ElseIf
lima.Text = "" Then
lima.Text = empat.Text
empat.Text = ""
End If
If
satu.Text = "1" And dua.Text = "2"
And tiga.Text = "3"
And empat.Text = "4"
And lima.Text = "5"
And enam.Text = "6"
And tujuh.Text = "7"
And delapan.Text = "8"
And kosong.Text = ""
Then
MsgBox("Selamat
Anda Berhasil")
End If
BUTTON
5;
If dua.Text = "" Then
dua.Text = lima.Text
lima.Text = ""
ElseIf
empat.Text = "" Then
empat.Text = lima.Text
lima.Text = ""
ElseIf
enam.Text = "" Then
enam.Text = lima.Text
lima.Text = ""
ElseIf
delapan.Text = "" Then
delapan.Text = lima.Text
lima.Text = ""
End If
If
satu.Text = "1" And dua.Text = "2"
And tiga.Text = "3"
And empat.Text = "4"
And lima.Text = "5"
And enam.Text = "6"
And tujuh.Text = "7"
And delapan.Text = "8"
And kosong.Text = ""
Then
MsgBox("Selamat
Anda Berhasil")
End If
BUTTON
6;
If kosong.Text = "" Then
kosong.Text = enam.Text
enam.Text = ""
ElseIf
tiga.Text = "" Then
tiga.Text = enam.Text
enam.Text = ""
ElseIf
lima.Text = "" Then
lima.Text = enam.Text
enam.Text = ""
End If
If
satu.Text = "1" And dua.Text = "2"
And tiga.Text = "3"
And empat.Text = "4"
And lima.Text = "5"
And enam.Text = "6"
And tujuh.Text = "7"
And delapan.Text = "8"
And kosong.Text = ""
Then
MsgBox("Selamat
Anda Berhasil")
End If
BUTTON
7;
If empat.Text = "" Then
empat.Text = tujuh.Text
tujuh.Text = ""
ElseIf
delapan.Text = "" Then
delapan.Text = tujuh.Text
tujuh.Text = ""
End If
If
satu.Text = "1" And dua.Text = "2"
And tiga.Text = "3"
And empat.Text = "4"
And lima.Text = "5"
And enam.Text = "6"
And tujuh.Text = "7"
And delapan.Text = "8"
And kosong.Text = ""
Then
MsgBox("Selamat
Anda Berhasil")
End If
BUTTON
8;
If tujuh.Text = "" Then
tujuh.Text = delapan.Text
delapan.Text = ""
ElseIf
kosong.Text = "" Then
kosong.Text = delapan.Text
delapan.Text = ""
ElseIf
lima.Text = "" Then
lima.Text = delapan.Text
delapan.Text = ""
End If
If
satu.Text = "1" And dua.Text = "2"
And tiga.Text = "3"
And empat.Text = "4"
And lima.Text = "5"
And enam.Text = "6"
And tujuh.Text = "7"
And delapan.Text = "8"
And kosong.Text = ""
Then
MsgBox("Selamat
Anda Berhasil")
End If
BUTTON
KOSONG;
If enam.Text = "" Then
enam.Text = kosong.Text
kosong.Text = ""
ElseIf
delapan.Text = "" Then
delapan.Text = kosong.Text
kosong.Text = ""
End If
If
satu.Text = "1" And dua.Text = "2"
And tiga.Text = "3"
And empat.Text = "4"
And lima.Text = "5"
And enam.Text = "6"
And tujuh.Text = "7"
And delapan.Text = "8"
And kosong.Text = ""
Then
MsgBox("Selamat
Anda Berhasil")
End If
Lalu kita Run/Jalankan
Dan hasilnya seperti di samping ini:
Lalu siap untuk dimainkan, setelah menang akan muncul
seperti di bawah ini:
Untuk Programnya silahkan download dibawah ini;