Program Visual Basic Menciptakan Puzzle 3 X 3

Design form menyerupai berikut ini :

Berikut merupakan aktivitas untuk permainan puzzle tersebut.

Private Sub cek()
    If (Command1.Caption = “1” And Command2.Caption = “2” And Command3.Caption = “3” And Command4.Caption = “4”) Then
        If (Command5.Caption = “5” And Command6.Caption = “6” And Command7.Caption = “7”) Then
            If (Command8.Caption = “8”) Then
                MsgBox (“Selesai”)
            End If
        End If
    End If
End Sub
   
Private Sub Command1_Click()
        If Command2.Visible = False Then
            Command2.Visible = True
            Command1.Visible = False
            Command2.Caption = Command1.Caption
        ElseIf Command4.Visible = False Then
            Command4.Visible = True
            Command1.Visible = False
            Command4.Caption = Command1.Caption
        End If
        Call cek
End Sub

Private Sub Command2_Click()
        If Command1.Visible = False Then
            Command1.Visible = True
            Command2.Visible = False
            Command1.Caption = Command2.Caption
        ElseIf Command3.Visible = False Then
            Command3.Visible = True
            Command2.Visible = False
            Command3.Caption = Command2.Caption
        ElseIf Command5.Visible = False Then
            Command5.Visible = True
            Command2.Visible = False
            Command5.Caption = Command2.Caption
        End If
        Call cek
End Sub

Private Sub Command3_Click()
        If Command2.Visible = False Then
            Command2.Visible = True
            Command3.Visible = False
            Command2.Caption = Command3.Caption
        ElseIf Command6.Visible = False Then
            Command6.Visible = True
            Command3.Visible = False
            Command6.Caption = Command3.Caption
        End If
        Call cek
End Sub

Private Sub Command4_Click()
        If Command1.Visible = False Then
            Command1.Visible = True
            Command4.Visible = False
            Command1.Caption = Command4.Caption
        ElseIf Command5.Visible = False Then
            Command5.Visible = True
            Command4.Visible = False
            Command5.Caption = Command4.Caption
        ElseIf Command7.Visible = False Then
            Command7.Visible = True
            Command4.Visible = False
            Command7.Caption = Command4.Caption
        End If
        Call cek
End Sub

Private Sub Command5_Click()
        If Command2.Visible = False Then
            Command2.Visible = True
            Command5.Visible = False
            Command2.Caption = Command5.Caption
        ElseIf Command4.Visible = False Then
            Command4.Visible = True
            Command5.Visible = False
            Command4.Caption = Command5.Caption
        ElseIf Command6.Visible = False Then
            Command6.Visible = True
            Command5.Visible = False
            Command6.Caption = Command5.Caption
        ElseIf Command8.Visible = False Then
            Command8.Visible = True
            Command5.Visible = False
            Command8.Caption = Command5.Caption
        End If
        Call cek
End Sub

Private Sub Command6_Click()
        If Command3.Visible = False Then
            Command3.Visible = True
            Command6.Visible = False
            Command3.Caption = Command6.Caption
        ElseIf Command9.Visible = False Then
            Command9.Visible = True
            Command6.Visible = False
            Command9.Caption = Command6.Caption
        ElseIf Command5.Visible = False Then
            Command5.Visible = True
            Command6.Visible = False
            Command5.Caption = Command6.Caption
        End If
        Call cek
End Sub

Private Sub Command7_Click()
        If Command8.Visible = False Then
            Command8.Visible = True
            Command7.Visible = False
            Command8.Caption = Command7.Caption
        ElseIf Command4.Visible = False Then
            Command4.Visible = True
            Command7.Visible = False
            Command4.Caption = Command7.Caption
        End If
        Call cek
End Sub

Private Sub Command8_Click()
        If Command7.Visible = False Then
            Command7.Visible = True
            Command8.Visible = False
            Command7.Caption = Command8.Caption
        ElseIf Command9.Visible = False Then
            Command9.Visible = True
            Command8.Visible = False
            Command9.Caption = Command8.Caption
        ElseIf Command5.Visible = False Then
            Command5.Visible = True
            Command8.Visible = False
            Command5.Caption = Command8.Caption
        End If
        Call cek
End Sub

Private Sub Command9_Click()
        If Command6.Visible = False Then
            Command6.Visible = True
            Command9.Visible = False
            Command6.Caption = Command9.Caption
        ElseIf Command8.Visible = False Then
            Command8.Visible = True
            Command9.Visible = False
            Command8.Caption = Command9.Caption
        End If
        Call cek
End Sub

Private Sub Acak()
        Dim a, c, m, i, y As Byte
        Dim x(10) As Byte
       
        For i = 0 To 9
            x(i) = i
        Next i
        a = 4
        c = 1
        m = 9
        x(0) = Rnd(9)
        For i = 1 To 9
            x(i) = (a * x(i – 1) + c) Mod m
            If x(i) = 0 Then
                y = i
            End If
        Next
        Command1.Caption = x(0)
        Command2.Caption = x(1)
        Command3.Caption = x(2)
        Command4.Caption = x(3)
        Command5.Caption = x(4)
        Command6.Caption = x(5)
        Command7.Caption = x(6)
        Command8.Caption = x(7)
        Command9.Caption = x(8)
        If y = 1 Then
            Command2.Caption = Command1.Caption
            Command1.Caption = x(y)
        ElseIf y = 2 Then
            Command3.Caption = Command1.Caption
            Command1.Caption = x(y)
        ElseIf y = 3 Then
            Command4.Caption = Command1.Caption
            Command1.Caption = x(y)
        ElseIf y = 4 Then
            Command5.Caption = Command1.Caption
            Command1.Caption = x(y)
        ElseIf y = 5 Then
            Command6.Caption = Command1.Caption
            Command1.Caption = x(y)
        ElseIf y = 6 Then
            Command7.Caption = Command1.Caption
            Command1.Caption = x(y)
        ElseIf y = 7 Then
            Command8.Caption = Command1.Caption
            Command1.Caption = x(y)
        ElseIf y = 8 Then
            Command9.Caption = Command1.Caption
            Command1.Caption = x(y)
        End If
End Sub

Private Sub Form_Load()
        Acak
End Sub

Demikianlah aktivitas visual basic membuat puzzle 3 x 3

Demikian yang dapat kami share kepada sobat source code aplikasi pada kesempatan ini, semoga dapat bermanfaat dan bisa menjadi referensi pemrograman bagi anda. Jangan lupa like Fan Page kami, dan SUBSCRIBE Channel Youtube kami untuk dapatkan update source code aplikasi terbaru.
Ahmad Code

Share
Published by
Ahmad Code

Recent Posts

Source Code Aplikasi Sistem Rekam Medis PHP+MYSQL

dalam dunia medispun telah menggunakan system komputasi, berupa aplikasi berbasis desktop maupun under web. kali…

5 hours ago

Source code aplikasi managemen RT-RW berbasis website

Aplikasi web merupakan salah satu media yang tepat untuk memberikan informasi kepada warga atau masyarakat…

11 hours ago

Source code Aplikasi Sistem Informasi Akademik Sekolah Menggunkan PHP MySQL

Aplikasi Sistem Informasi Akedemik Sekolah menggunkan PHP MySQl atau berbasis web ini merupakan sebuah sebuah…

17 hours ago

Source Code Aplikasi Website Portal Menggunakan PHP MySQL

Pada kesempatan ini saya kembali membagikan buat anda pencinta aplikasi berbasis web yaitu source kode…

23 hours ago

Source code Aplikasi Website Pendaftaran Online Menggunakan PHP Mysql

Buat sobat semua yang lagi membutuhkan sedikit pencerahan tentang membuat website sistem pendaftaran online, pada…

1 day ago

Source code Aplikasi Penjualan Sepeda Motor Menggunakan PHP dan MySQL

Aplikasi Penjualan Sepeda Motor berbasis web ini adalah merupakan aplikasi untuk memberikan kemudahan dalam proses…

1 day ago