请问这个判断有何作用?
Option Explicit
Dim M_DragX, M_DragY As Integer
Dim Img_OldX, Img_OldY As Integer
Dim Img_NewX, Img_NewY As Integer
Dim m_lngTime As Long
Private Sub Form_Load()
Dim PicPos As String
Dim I As Integer
PicPos = App.Path
If Right(PicPos, 1) <> "\" Then
PicPos = PicPos & "\"
End If
For I = 0 To 3
imgSoldier(I).Picture = LoadPicture(PicPos & "soldier.gif")
imgSoldier(I).Enabled = False
Next
End Sub
Private Sub cmdExit_Click()
End
End Sub
Private Sub cmdStart_Click()
Dim I As Integer
CmdStart.Caption = "重新开始"
m_lngTime = 0
imgSoldier(0).Move 0, 4000
imgSoldier(1).Move 1000, 3000
imgSoldier(2).Move 2000, 3000
imgSoldier(3).Move 3000, 4000
For I = 0 To 3
imgSoldier(I).Enabled = True
Next I
End Sub
Private Sub imgGuanyu_Click()
End Sub
Private Sub picFrame_DragDrop(Source As Control, X As Single, Y As Single)
Source.Move (X - M_DragX), (Y - M_DragY)
Img_NewX = Source.Left
Img_NewY = Source.Top
If (Abs(Img_NewX - Img_OldX) > Abs(Img_NewY - Img_OldY)) Then
If (Img_NewX - Img_OldX > 0) Then
Source.Move Img_OldX + 1000, Img_OldY
Else
Source.Move Img_OldX - 1000, Img_OldY
End If
Else
If (Img_NewY - Img_OldY > 0) Then
Source.Move Img_OldX, Img_OldY + 1000
Else
Source.Move Img_OldX, Img_OldY - 1000
End If
End If
Dim intCenterX, intCenterY As Integer
intCenterX = Source.Left + Source.Width / 2
intCenterY = Source.Top + Source.Height / 2
Dim intTemp As Integer
For intTemp = 0 To 3
If (Source.Tag <> imgSoldier(intTemp).Tag) Then
If (PointInRect(imgSoldier(intTemp), intCenterX, intCenterY)) Then
Source.Move Img_OldX, Img_OldY
End If
End If
Next intTemp
End Sub
Private Function PointInRect(Image As Control, ByVal X As Integer, ByVal Y As Integer) As Boolean
If (X >= Image.Left And X <= (Image.Left + Image.Width) And Y >= Image.Top And Y <= (Image.Top + Image.Height)) Then
PointInRect = True
Else
PointInRect = False
End If
End Function
Private Sub imgSoldier_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
imgSoldier(Index).Drag vbBeginDrag
M_DragX = X
M_DragY = Y
Img_OldX = imgSoldier(Index).Left
Img_OldY = imgSoldier(Index).Top
End Sub
请问 If (Source.Tag <> imgSoldier(intTemp).Tag) Then
这个判断有何作用?Source.Tag 怎么用?在这道题中什么情况下Source.Tag 和 imgSoldier(intTemp).Tag会相等?谢谢!!