Kamis, 10 Maret 2011
Public Class Puzzle2
Dim tampung1, tampung2 As String
Private Sub Puzzle2_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated
kosong()
End Sub
Private Sub tukar()
If tampung1 = Button1.Text Then
Button1.Text = tampung2
ElseIf tampung1 = Button2.Text Then
Button2.Text = tampung2
ElseIf tampung1 = Button3.Text Then
Button3.Text = tampung2
ElseIf tampung1 = Button4.Text Then
Button4.Text = tampung2
ElseIf tampung1 = Button5.Text Then
Button5.Text = tampung2
ElseIf tampung1 = Button6.Text Then
Button6.Text = tampung2
ElseIf tampung1 = Button7.Text Then
Button7.Text = tampung2
ElseIf tampung1 = Button8.Text Then
Button8.Text = tampung2
ElseIf tampung1 = Button9.Text Then
Button9.Text = tampung2
End If
End Sub
Private Sub kosong()
tampung1 = " "
tampung2 = " "
End Sub
Private Sub guna()
Button1.Enabled = True
Button2.Enabled = True
Button3.Enabled = True
Button4.Enabled = True
Button5.Enabled = True
Button6.Enabled = True
Button7.Enabled = True
Button8.Enabled = True
Button9.Enabled = True
End Sub
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
If tampung1 = " " Then
tampung1 = Button1.Text
Button1.Enabled = False
Else
tampung2 = Button1.Text
tukar()
Button1.Text = tampung1
kosong()
guna()
End If
cek()
End Sub
Private Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
If tampung1 = " " Then
tampung1 = Button2.Text
Button2.Enabled = False
Else
tampung2 = Button2.Text
tukar()
Button2.Text = tampung1
kosong()
guna()
End If
cek()
End Sub
Private Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button3.Click
If tampung1 = " " Then
tampung1 = Button3.Text
Button3.Enabled = False
Else
tampung2 = Button3.Text
tukar()
Button3.Text = tampung1
kosong()
guna()
End If
cek()
End Sub
Private Sub Button4_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button4.Click
If tampung1 = " " Then
tampung1 = Button4.Text
Button4.Enabled = False
Else
tampung2 = Button4.Text
tukar()
Button4.Text = tampung1
kosong()
guna()
End If
cek()
End Sub
Private Sub Button5_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button5.Click
If tampung1 = " " Then
tampung1 = Button5.Text
Button5.Enabled = False
Else
tampung2 = Button5.Text
tukar()
Button5.Text = tampung1
kosong()
guna()
End If
cek()
End Sub
Private Sub Button6_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button6.Click
If tampung1 = " " Then
tampung1 = Button6.Text
Button6.Enabled = False
Else
tampung2 = Button6.Text
tukar()
Button6.Text = tampung1
kosong()
guna()
End If
cek()
End Sub
Private Sub Button7_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button7.Click
If tampung1 = " " Then
tampung1 = Button7.Text
Button7.Enabled = False
Else
tampung2 = Button7.Text
tukar()
Button7.Text = tampung1
kosong()
guna()
End If
cek()
End Sub
Private Sub Button8_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button8.Click
If tampung1 = " " Then
tampung1 = Button8.Text
Button8.Enabled = False
Else
tampung2 = Button8.Text
tukar()
Button8.Text = tampung1
kosong()
guna()
End If
cek()
End Sub
Private Sub Button9_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button9.Click
If tampung1 = " " Then
tampung1 = Button9.Text
Button9.Enabled = False
Else
tampung2 = Button9.Text
tukar()
Button9.Text = tampung1
kosong()
guna()
End If
cek()
End Sub
Private Sub cek()
If (Button1.Text = "A" And Button2.Text = "B" And Button3.Text = "C" And Button4.Text = "D") Then
If (Button5.Text = "E" And Button6.Text = "F" And Button7.Text = "G") Then
If (Button8.Text = "H" And Button9.Text = "I") Then
MessageBox.Show("Selesai")
Close()
End If
End If
End If
End Sub
End Class
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar