End Sub
Sub Form_Load()
isBoxExist
= False
'initialize the rectangle
minX = -10
maxX = 10
minY =
-10
maxY = 10
End Sub
Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single,
Y As Single)
If Button = 1 Then
'if a rectangle is already drawn, delete
it
If isRectExist
Then
Picture1.Cls
isBoxExist = False
End
If
minX =
X
maxY =
Y
maxX =
X
maxY = Y
End If
End Sub
Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As
Single, Y As Single)
'Drawing the
rectangle
If Button = 1
Then
Picture1.DrawMode =
10
Picture1.Line (minX,
maxY)-(maxX, minY), , B
maxX =
X
minY =
Y
Picture1.Line (minX,
maxY)-(maxX, minY), , B
Picture1.DrawMode = 13
End If
End
Sub
Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer,
X As Single, Y As Single)
'update the isRectExist
variable, so the next time the user will start drawing the rectangle,
'we
will know that a rectangle is already exist, and we will delete the old
rectangle
isRectExist = True
End Sub