01.
Public
Class
Form1
02.
Dim
lst
As
New
List(Of PictureBox)
03.
Private
Sub
Form1_Load(sender
As
Object
, e
As
EventArgs)
Handles
MyBase
.Load
04.
lst.Add(PictureBox1)
05.
lst.Add(PictureBox2)
06.
07.
For
Each
pic
As
PictureBox
In
lst
08.
Dim
a
As
Double
= PictureBox3.Location.X
09.
Dim
b
As
Double
= PictureBox3.Location.Y
10.
Dim
c
As
Double
= b + PictureBox3.Height
11.
Dim
d
As
Double
= a + PictureBox3.Width
12.
If
a = pic.Location.X + pic.Width
Or
d = pic.Location.X
Or
b = pic.Location.Y + pic.Height
Or
c = pic.Location.Y
Then
13.
MessageBox.Show(
"มีส่วนที่ชนกันอยู่"
)
14.
lst.Add(PictureBox3)
15.
Exit
Sub
16.
End
If
17.
Next
18.
MessageBox.Show(
"ไม่มีส่วนที่ชนกันเลย"
)
19.
End
Sub
20.
End
Class