Puzzle
cara unruk membuat puzzle si atas sebagai berikut skrip yang di buruhkan.
Copy scrip di visual basic
Public Class Form1
Dim smt As String
Dim acak As Integer
Dim b, s As Boolean
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
For Each kontrol In Me.Controls
kontrol.enabled = False
Button10.Enabled = True
Button12.Enabled = True
Next
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
b = True
s = False
If Button2.Visible = s Then
Button2.Visible = b
Button1.Visible = s
Button2.Text = Button1.Text
Else
If Button4.Visible = s Then
Button4.Visible = b
Button1.Visible = s
Button4.Text = Button1.Text
End If
End If
cek()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
b = True
s = False
If Button1.Visible = s Then
Button1.Visible = b
Button2.Visible = s
Button1.Text = Button2.Text
Else If Button3.Visible = s Then
Button3.Visible = b
Button2.Visible = s
Button3.Text = Button2.Text
Else If Button5.Visible = s Then
Button5.Visible = b
Button2.Visible = s
Button5.Text = Button2.Text
End If
cek()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
b = True
s = False
If Button2.Visible = s Then
Button2.Visible = b
Button3.Visible = s
Button2.Text = Button3.Text
Else
If Button6.Visible = s Then
Button6.Visible = b
Button3.Visible = s
Button6.Text = Button3.Text
End If
End If
cek()
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
b = True
s = False
If Button1.Visible = s Then
Button1.Visible = b
Button4.Visible = s
Button1.Text = Button4.Text
ElseIf Button5.Visible = s Then
Button5.Visible = b
Button4.Visible = s
Button5.Text = Button4.Text
Else If Button7.Visible = s Then
Button7.Visible = b
Button4.Visible = s
Button7.Text = Button4.Text
End If
cek()
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
b = True
s = False
If Button2.Visible = s Then
Button2.Visible = b
Button5.Visible = s
Button2.Text = Button5.Text
Else If Button4.Visible = s Then
Button4.Visible = b
Button5.Visible = s
Button4.Text = Button5.Text
Else If Button6.Visible = s Then
Button6.Visible = b
Button5.Visible = s
Button6.Text = Button5.Text
Else If Button8.Visible = s Then
Button8.Visible = b
Button5.Visible = s
Button8.Text = Button5.Text
End If
cek()
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
b = True
s = False
If Button3.Visible = s Then
Button3.Visible = b
Button6.Visible = s
Button3.Text = Button6.Text
Else If Button9.Visible = s Then
Button9.Visible = b
Button6.Visible = s
Button9.Text = Button6.Text
ElseIf Button5.Visible = s Then
Button5.Visible = b
Button6.Visible = s
Button5.Text = Button6.Text
End If
cek()
End Sub
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
b = True
s = False
If Button8.Visible = s Then
Button8.Visible = b
Button7.Visible = s
Button8.Text = Button7.Text
Else
If Button4.Visible = s Then
Button4.Visible = b
Button7.Visible = s
Button4.Text = Button7.Text
End If
End If
cek()
End Sub
Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
b = True
s = False
If Button7.Visible = s Then
Button7.Visible = b
Button8.Visible = s
Button7.Text = Button8.Text
ElseIf Button9.Visible = s Then
Button9.Visible = b
Button8.Visible = s
Button9.Text = Button8.Text
ElseIf Button5.Visible = s Then
Button5.Visible = b
Button8.Visible = s
Button5.Text = Button8.Text
End If
cek()
End Sub
Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
b = True
s = False
If Button6.Visible = s Then
Button6.Visible = b
Button9.Visible = s
Button6.Text = Button9.Text
Else
If Button8.Visible = s Then
Button8.Visible = b
Button9.Visible = s
Button8.Text = Button9.Text
End If
End If
cek()
End Sub
Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click
Dim kontrol As Windows.Forms.Control
For Each kontrol In Me.Controls
kontrol.Enabled = True
Button10.Enabled = True
Button12.Enabled = True
smt = Button1.Text
Button1.Text = Button3.Text
Button3.Text = Button2.Text
Button2.Text = Button5.Text
Button5.Text = Button6.Text
Button6.Text = Button7.Text
Button7.Text = Button8.Text
Button8.Text = Button4.Text
Button4.Text = Button6.Text
Button6.Text = smt
Button12.Enabled = True
Button11.Enabled = True
Label1.Enabled = True
Label1.Text = "Selamat Mencoba"
Next
End Sub
Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click
If MsgBox("Apakah Anda Ingin Mengulang ?", vbYesNo + vbQuestion + vbDefaultButton2, "Anda Ingin Mengulang") _
= vbYes Then Application.Restart()
End Sub
Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click
If MsgBox("Apakah Anda Yakin Akan Keluar ?", vbYesNo + vbQuestion + vbDefaultButton2, "Keluar") = _
vbYes Then Me.Close()
End Sub
Private Sub cek()
If Button1.Text = "1" And Button2.Text = "2" And Button3.Text = "3" _
And Button4.Text = "4" And Button5.Text = "5" And Button6.Text = "6" _
And Button7.Text = "7" And Button8.Text = "8" Then MessageBox.Show("selamat anda berhasil")
End Sub
End Class
Tidak ada komentar:
Posting Komentar