A. Modifikasi program If dan Case
Disini saya akan memodifikasi program if dan case. Dengan menambah Button isi data.dan menonaktifkan beberapa tombol dan isian.
1.
Saat
form dijalankan : semua isian tidak aktif, tombol isidata dan tutup aktif,
tombol clear tidak aktif
Dan
ini listing programnya
2.
Saat
ditekan tombol isi data : kode barang,jumlah barang, cara beli, tombol clear
aktif, tombol isi data tidak aktif
Dan ini
listing programnya
2.
Saat
ditekan tombol clear sama dengan saat form dijalankan
Dan
ini listing programnya
PERMAINAN PUZZLE SEDERHANA
Sekarang saya membuat permainan puzzle sederhana.
1.
Saat
form dijalankan posisi angka acak
2.
Saat
ditekan tombol yang terletak didekat tombol kosong maka tombol tersebut akan
menempati tombol kosong, begitu seterusnya sampai dengan angkanya tersusun dari
1 sampai 8 dan muncul pesan “Kamu Berhasil!”
3.
Saat
menekan tombol Keluar
Dan inilah listing program Puzzle
yang saya buat :
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("Kamu Berhasil! ")
End
If
End If
End If
End Sub
Private Sub
Henti_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Henti.Click
Timer1.Stop()
Satu.Text = "7"
Dua.Text = "6"
Tiga.Text = "8"
Empat.Text = "5"
Lima.Text = "1"
Enam.Text = "3"
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("Apakah
Anda Yakin ? ", vbYesNo + vbQuestion + vbDefaultButton2, "Exit Game") = 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
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
Private Sub
Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
MyBase.Load
Timer1.Enabled = True
End Sub
End Class
Sekian penjelasan pembuatan program dari saya. Semoga bermanfaat. Terima kasih
Sekian penjelasan pembuatan program dari saya. Semoga bermanfaat. Terima kasih