相关代码如下(VB):
blnMatch = False
For i = 0 To UBound(rgqSource, 2) 'height
For j = 0 To UBound(rgqSource, 1) 'width
For m = 0 To UBound(rgqMatch, 2) 'height
For n = 0 To UBound(rgqMatch, 1) 'width
v = i + m 'height
w = j + n 'width
If w <= UBound(rgqSource, 1) And v <= UBound(rgqSource, 2) Then
If rgqSource(w, v) <> rgqMatch(n, m) Then
GoTo NextCol
End If
Else
GoTo NextRow
End If
Next
Next
blnMatch = True
GoTo NextStep
NextCol:
Next
NextRow:
Next
NextStep:
If blnMatch = True Then
MsgBox "Match! X: " & j & ", Y: " & i
Else
MsgBox "Not Match!"
End If