Berikut source code dari program puzzle.
Public Class Form1
Dim tampung
As String
Dim run As Boolean = False
Dim acak As Integer
Private Sub
Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
Me.Close()
End Sub
Private Sub Bt8_Click(ByVal
sender As System.Object,
ByVal e As
System.EventArgs) Handles
Bt8.Click
If Bt9.Text =
"" then
tampung = Bt9.Text
Bt9.Text = Bt8.Text
Bt8.Text = tampung
End If
If
Bt7.Text = "" Then
tampung = Bt7.Text
Bt7.Text = Bt8.Text
Bt8.Text = tampung
End If
If Bt5.Text = ""
Then
tampung = Bt5.Text
Bt5.Text = Bt8.Text
Bt8.Text = tampung
End If
End Sub
Private Sub Bt9_Click(ByVal
sender As System.Object,
ByVal e As
System.EventArgs) Handles
Bt9.Click
If
Bt6.Text = "" Then
tampung = Bt6.Text
Bt6.Text = Bt9.Text
Bt9.Text = tampung
End If
If
Bt8.Text = "" Then
tampung = Bt8.Text
Bt8.Text = Bt9.Text
Bt9.Text = tampung
End If
If
Bt1.Text = "1" And Bt2.Text = "2"
And Bt3.Text = "3"
And Bt4.Text = "4"
And
Bt5.Text
= "5" And
Bt6.Text = "6" And Bt7.Text = "7"
And Bt8.Text = "8" And Bt9.Text
= "" Then
MsgBox("Selamat
anda menang") ' dalam praktiknya, tombol 9 selalu
ditekan terakhir kali sehingga bisa dimanfaatkan untuk
menampilkan message box
End If
End Sub
Private Sub Bt6_Click(ByVal
sender As System.Object,
ByVal e As
System.EventArgs) Handles
Bt6.Click
If
Bt9.Text = "" Then
tampung = Bt9.Text
Bt9.Text = Bt6.Text
Bt6.Text = tampung
End If
If
Bt3.Text = "" Then
tampung = Bt3.Text
Bt3.Text = Bt6.Text
Bt6.Text = tampung
End If
If Bt5.Text = ""
Then
tampung = Bt5.Text
Bt5.Text = Bt6.Text
Bt6.Text = tampung
End If
End Sub
Private Sub Bt5_Click(ByVal
sender As System.Object,
ByVal e As
System.EventArgs) Handles
Bt5.Click
If
Bt6.Text = "" Then
tampung = Bt6.Text
Bt6.Text = Bt5.Text
Bt5.Text = tampung
End If
If
Bt8.Text = "" Then
tampung = Bt8.Text
Bt8.Text = Bt5.Text
Bt5.Text = tampung
End If
If
Bt4.Text = "" Then
tampung = Bt4.Text
Bt4.Text = Bt5.Text
Bt5.Text = tampung
End If
If
Bt2.Text = "" Then
tampung = Bt2.Text
Bt2.Text = Bt5.Text
Bt5.Text = tampung
End If
End Sub
Private Sub Bt7_Click(ByVal
sender As System.Object,
ByVal e As
System.EventArgs) Handles
Bt7.Click
If
Bt8.Text = "" Then
tampung = Bt8.Text
Bt8.Text = Bt7.Text
Bt7.Text = tampung
End If
If
Bt4.Text = "" Then
tampung = Bt4.Text
Bt4.Text = Bt7.Text
Bt7.Text = tampung
End If
End Sub
Private Sub Bt4_Click(ByVal
sender As System.Object,
ByVal e As
System.EventArgs) Handles
Bt4.Click
If
Bt1.Text = "" Then
tampung = Bt1.Text
Bt1.Text = Bt4.Text
Bt4.Text = tampung
End If
If
Bt5.Text = "" Then
tampung = Bt5.Text
Bt5.Text = Bt4.Text
Bt4.Text = tampung
End If
If
Bt7.Text = "" Then
tampung = Bt7.Text
Bt7.Text = Bt4.Text
Bt4.Text = tampung
End If
End Sub
Private Sub Bt1_Click(ByVal
sender As System.Object,
ByVal e As
System.EventArgs) Handles
Bt1.Click
If
Bt2.Text = "" Then
tampung = Bt2.Text
Bt2.Text = Bt1.Text
Bt1.Text = tampung
End If
If
Bt4.Text = "" Then
tampung = Bt4.Text
Bt4.Text = Bt1.Text
Bt1.Text = tampung
End If
End Sub
Private Sub Bt2_Click(ByVal
sender As System.Object,
ByVal e As
System.EventArgs) Handles
Bt2.Click
If
Bt1.Text = "" Then
tampung = Bt1.Text
Bt1.Text = Bt2.Text
Bt2.Text = tampung
End If
If
Bt5.Text = "" Then
tampung = Bt5.Text
Bt5.Text = Bt2.Text
Bt2.Text = tampung
End If
If
Bt3.Text = "" Then
tampung = Bt3.Text
Bt3.Text = Bt2.Text
Bt2.Text = tampung
End If
End Sub
Private Sub Bt3_Click(ByVal
sender As System.Object,
ByVal e As
System.EventArgs) Handles
Bt3.Click
If
Bt2.Text = "" Then
tampung = Bt2.Text
Bt2.Text = Bt3.Text
Bt3.Text = tampung
End If
If
Bt6.Text = "" Then
tampung = Bt6.Text
Bt6.Text = Bt3.Text
Bt3.Text = tampung
End If
End Sub
Private Sub btacak_Click(ByVal
sender As System.Object,
ByVal e As
System.EventArgs) Handles
btacak.Click
run = Not run
Timer1.Enabled = run
If run
= False Then
btacak.Text = "Acak"
Else
btacak.Text = "Stop"
End If
End Sub
Private Sub Timer1_Tick(ByVal
sender As System.Object,
ByVal e As
System.EventArgs) Handles
Timer1.Tick
Dim
cadangan As String
Do
run = Not
run
cadangan = Bt2.Text
Bt2.Text = Bt8.Text
Bt8.Text = Bt6.Text
Bt6.Text = Bt4.Text
Bt4.Text = Bt1.Text
Bt1.Text = Bt3.Text
Bt3.Text = Bt7.Text
Bt7.Text = Bt5.Text
Bt5.Text = Bt9.Text
Bt9.Text = cadangan
Loop Until run = True
End Sub
Private Sub Button2_Click(ByVal
sender As System.Object,
ByVal e As
System.EventArgs) Handles
btmudah.Click
Bt1.Text = "1"
Bt2.Text = "2"
Bt3.Text = "3"
Bt4.Text = "4"
Bt5.Text = ""
Bt6.Text = "6"
Bt7.Text = "7"
Bt8.Text = "5"
Bt9.Text = "8"
End Sub
End Class
0 comments:
Post a Comment