Bab I Visual Basic 6: &H00C0FFFF&

You might also like

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 9

BAB I Visual Basic 6

ChanelPacitan.blogspot.com Menyediakan Informasi dan Pengetahuan Seputar dunia TIK Kunjngi Ya..... mailto:nantaarga@gmail.com?subject=Informasi dan Pen

Launching ChanelPacitan
Sekarang kita akan belajar cara membuat Game Puzzle dengan VB6 Full Versio / Portable sama saja Buka VB6.exe Klik New Project Beri nama Project nya (PrjPuzzle) Next Step Tambahkan 1 Form beri nama FrmPuzzle Rincian Form di bawah Komponen Form1 Command1 Command2 Command3 Command4 Command5 Command6 Command7 Command8 Command9 PictureBox1 Label1 Label2 Command10 Module Name frmPuzzle P1 P2 P3 P4 P5 P6 P7 P8 P9 Picture1 Label LblJmlPIndah CmdAcak ModFunction Caption Puzzle Jmlh Pindah 0 Acak Keterangan Lain Wrna Background &H00C0FFFF& Warna Merah -

Untuk Penataan Form Kurang lebih seperti Gambar di bawah

Untuk kode Bisa di lihat bawah ini Source Code untuk Form Sebelum anda memasukkan Code di bawah kepada Form pastikan name nya sudah cocok pada yang di atas Private Sub CmdAcak_Click() LblJmlPIndah.Caption = 0 Dim a, b, c, d, e, f, g, h, i As Variant a = arr(0, 1) b = arr(1, 1) c = arr(0, 2) d = arr(1, 2) e = arr(2, 1) f = arr(2, 2) g = arr(1, 0) h = arr(2, 0) i = arr(0, 0) arr(0, arr(2, arr(0, arr(1, arr(2, arr(1, arr(2, arr(0, arr(1, 0) 2) 1) 2) 0) 1) 1) 2) 0) = = = = = = = = = f h c a g d b i e = = = = = = = = = arr(0, arr(0, arr(0, arr(1, arr(1, arr(1, arr(2, arr(2, arr(2, 0) 1) 2) 0) 1) 2) 0) 1) 2)

P1.Caption P2.Caption P3.Caption P4.Caption P5.Caption P6.Caption P7.Caption P8.Caption P9.Caption

If P1.Caption &H8000000F If P2.Caption &H8000000F If P3.Caption &H8000000F If P4.Caption &H8000000F

= "" Then P1.BackColor = &HFF& Else P1.BackColor = = "" Then P2.BackColor = &HFF& Else P2.BackColor = = "" Then P3.BackColor = &HFF& Else P3.BackColor = = "" Then P4.BackColor = &HFF& Else P4.BackColor =

If P5.Caption &H8000000F If P6.Caption &H8000000F If P7.Caption &H8000000F If P8.Caption &H8000000F If P9.Caption &H8000000F End Sub

= "" Then P5.BackColor = &HFF& Else P5.BackColor = = "" Then P6.BackColor = &HFF& Else P6.BackColor = = "" Then P7.BackColor = &HFF& Else P7.BackColor = = "" Then P8.BackColor = &HFF& Else P8.BackColor = = "" Then P9.BackColor = &HFF& Else P9.BackColor =

Private Sub P1_Click() If P2.Caption = "" Then LblJmlPIndah.Caption = LblJmlPIndah.Caption + 1 Call Pindah_Kanan(P1, P2) End If If P4.Caption = "" Then LblJmlPIndah.Caption = LblJmlPIndah.Caption + 1 Call Pindah_Bawah(P1, P4) End If End Sub Private Sub P2_Click() If P1.Caption = "" Then LblJmlPIndah.Caption = LblJmlPIndah.Caption + 1 Call Pindah_Kiri(P1, P2) End If If P3.Caption = "" Then LblJmlPIndah.Caption = LblJmlPIndah.Caption + 1 Call Pindah_Kanan(P2, P3) End If If P5.Caption = "" Then LblJmlPIndah.Caption = LblJmlPIndah.Caption + 1 Call Pindah_Bawah(P2, P5) End If End Sub Private Sub P3_Click() If P2.Caption = "" Then LblJmlPIndah.Caption = LblJmlPIndah.Caption + 1 Call Pindah_Kiri(P2, P3) End If If P6.Caption = "" Then LblJmlPIndah.Caption = LblJmlPIndah.Caption + 1 Call Pindah_Bawah(P3, P6) End If

End Sub Private Sub P4_Click() If P5.Caption = "" Then LblJmlPIndah.Caption = LblJmlPIndah.Caption + 1 Call Pindah_Kanan(P4, P5) End If If P1.Caption = "" Then LblJmlPIndah.Caption = LblJmlPIndah.Caption + 1 Call Pindah_Atas(P1, P4) End If If P7.Caption = "" Then LblJmlPIndah.Caption = LblJmlPIndah.Caption + 1 Call Pindah_Bawah(P4, P7) End If End Sub Private Sub P5_Click() If P2.Caption = "" Then LblJmlPIndah.Caption = LblJmlPIndah.Caption Call Pindah_Atas(P2, P5) End If If P8.Caption = "" Then LblJmlPIndah.Caption = LblJmlPIndah.Caption Call Pindah_Bawah(P5, P8) End If If P4.Caption = "" Then LblJmlPIndah.Caption = LblJmlPIndah.Caption Call Pindah_Kiri(P4, P5) End If If P6.Caption = "" Then LblJmlPIndah.Caption = LblJmlPIndah.Caption Call Pindah_Kanan(P5, P6) End If End Sub

+1

+1

+1

+1

Private Sub P6_Click() If P5.Caption = "" Then LblJmlPIndah.Caption = LblJmlPIndah.Caption + 1 Call Pindah_Kiri(P5, P6) End If If P3.Caption = "" Then LblJmlPIndah.Caption = LblJmlPIndah.Caption + 1 Call Pindah_Atas(P3, P6) End If If P9.Caption = "" Then LblJmlPIndah.Caption = LblJmlPIndah.Caption + 1 Call Pindah_Bawah(P6, P9) End If

End Sub Private Sub P7_Click() If P8.Caption = "" Then LblJmlPIndah.Caption = LblJmlPIndah.Caption + 1 Call Pindah_Kanan(P7, P8) End If If P4.Caption = "" Then LblJmlPIndah.Caption = LblJmlPIndah.Caption + 1 Call Pindah_Atas(P4, P7) End If End Sub Private Sub P8_Click() If P7.Caption = "" Then LblJmlPIndah.Caption = LblJmlPIndah.Caption + 1 Call Pindah_Kiri(P7, P8) End If If P9.Caption = "" Then LblJmlPIndah.Caption = LblJmlPIndah.Caption + 1 Call Pindah_Kanan(P8, P9) End If If P5.Caption = "" Then LblJmlPIndah.Caption = LblJmlPIndah.Caption + 1 Call Pindah_Atas(P5, P8) End If End Sub Private Sub P9_Click() If P8.Caption = "" Then LblJmlPIndah.Caption = LblJmlPIndah.Caption + 1 Call Pindah_Kiri(P8, P9) End If If P6.Caption = "" Then LblJmlPIndah.Caption = LblJmlPIndah.Caption + 1 Call Pindah_Atas(P6, P9) End If End Sub Private Sub Form_Load() LblJmlPIndah.Caption = 0 arr(0, 0) = 1 arr(0, 1) = 2 arr(0, 2) = 3 arr(1, 0) = 4 arr(1, 1) = 5 arr(1, 2) = 6 arr(2, 0) = 7 arr(2, 1) = 8 arr(2, 2) = ""

P1.Caption P2.Caption P3.Caption P4.Caption P5.Caption P6.Caption P7.Caption P8.Caption P9.Caption

= = = = = = = = =

arr(0, arr(0, arr(0, arr(1, arr(1, arr(1, arr(2, arr(2, arr(2,

0) 1) 2) 0) 1) 2) 0) 1) 2)

P9.BackColor = &HFF& End Sub

Klik dua kali Pada Module dan isikan Code di bawah ini ke Module Public arr(0 To 2, 0 To 2) As Variant Function Pindah_Kiri(P1 As CommandButton, P2 As CommandButton) P1.Caption = P2.Caption P2.Caption = "" P2.BackColor = &HFF& P1.BackColor = &H8000000F End Function Function Pindah_Kanan(P1 As CommandButton, P2 As CommandButton) P2.Caption = P1.Caption P1.Caption = "" P1.BackColor = &HFF& P2.BackColor = &H8000000F End Function Function Pindah_Atas(P3 As CommandButton, P4 As CommandButton) P3.Caption = P4.Caption P4.Caption = "" P4.BackColor = &HFF& P3.BackColor = &H8000000F End Function Function Pindah_Bawah(P3 As CommandButton, P4 As CommandButton) P4.Caption = P3.Caption P3.Caption = "" P3.BackColor = &HFF& P4.BackColor = &H8000000F End Function Apabila terjadi debug ChanelPacitan.blogspot.com dapat bertanya atau berkomentar di

You might also like