| 
				 (2)空位处理函数:empty_do(pic1,pic2) 
Private Function empty_do(pic1 As PictureBox, pic2 As PictureBox) 
Dim a, b As Integer 
'以下代码判断是否与无图像的图片框相邻,若相邻则交换 
If (pic1.Left = pic2.Left) Then 
    If (pic1.Top - pic2.Top = 1500 Or pic1.Top - pic2.Top = -1500) Then 
       Call jiaohuan(pic1, pic2) 
       b = 1 
     End If 
ElseIf (pic1.Top = pic2.Top) Then 
    If (pic1.Left - pic2.Left = 1500 Or pic1.Left - pic2.Left = -1500) Then 
       Call jiaohuan(pic1, pic2) 
       b = 1 
    End If 
End If 
'以下代码判断是否完成游戏,若完成则显示成功信息 
If (start = 1 And b = 1) Then 
    a = 0 
    While (a < 9 And Picture1(a).Left / 1500 = Int(a / 3) And Picture1(a).Top / 1500 = a Mod 3) 
        a = a + 1 
    Wend 
    If (a = 9) Then 
       Timer1.Enabled = False 
       MsgBox "恭喜你取得成功!请再接再厉!", , "祝贺" 
       start = 0 
       Command1(0).Caption = "开始游戏" 
    End If 
End If 
End Function 			
				 |