Dim Dizi(
![Cool](https://2img.net/i/fa/i/smiles/icon_cool.gif)
As Integer, Bos_x, Bos_y
Private Sub Command1_Click(Index As Integer)
y = (Command1(Index).Left - 315) / 500
x = (Command1(Index).Top - 315) / 500
If (Bos_x = x And Abs(Bos_y - y) = 1) Or _
(Bos_y = y And Abs(Bos_x - x) = 1) Then
Command1(Index).Left = 315 + 500 * Bos_y
Command1(Index).Top = 315 + 500 * Bos_x
Bos_x = x
Bos_y = y
End If
End Sub
Private Sub Form_Load()
Randomize
Bos_x = 0
Bos_y = 0
For i = 1 To 8
Dizi(i) = CInt(7 * Rnd) + 1
For j = 1 To i - 1
If Dizi(i) = Dizi(j) Then i = i - 1
Next
Next
For i = 1 To 8
Command1(i).Caption = i
Command1(i).Left = 315 + 500 * (Dizi(i) Mod 3)
Command1(i).Top = 315 + 500 * CInt(Dizi(i) \ 3)
Next
End Sub