Download Source Code Aplikasi

Program Visual Basic Menciptakan Puzzle 3 X 3

Monday, October 7th, 2019 - Puzzle, Visual Basic 6.0

Design form menyerupai berikut ini :

Program Visual Basic membuat Puzzle 3 X 3

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.
Download Source Code Aplikasi
Program Visual Basic Menciptakan Puzzle 3 X 3 | Ahmad Code | 4.5