假设有计算区域50X50的方格,现需要让该计算域中移除一个20X20的小方格,如图所示,在VB中有没有特定语句用于处理该情况?
Function InRect(r As Rect, p As Point) As Boolean
Return p.x > r.Left And p.x < r.Left + r.Width And p.y > r.Top And p.y < r.Top + r.Height
End Function
在你的程序里
Dim r As new Rect
r.Top = 15
r.Left = 15
r.Height = 20
r.Width = 20
...
for i = 0 to 50
for j = 0 to 50
Dim p As new Point
p.x = i
p.y = j
if InRect(r, p) then
不做处理
else
处理
end if
next
next