Dim xpt(100) As Integer
Dim ypt(100) As Integer
Dim num, num2 As Integer
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
red = RGB(255, 0, 0)
white = RGB(255, 255, 255)
green = RGB(0, 255, 0)
If (Button = 1) Then
num = num + 1
xpt(num) = X
ypt(num) = Y
If num = 1 Then
PSet (X, Y), green '繪點
ElseIf num = 2 Then
Line (xpt(2), ypt(2))-(xpt(1), ypt(1)), red, B '繪圖形
ElseIf xpt(num) >= xpt(1) And xpt(num) <= xpt(2) And ypt(num) >= ypt(1) And ypt(num) <= ypt(2) And num2 <> 1 Then
Print "inside"
ElseIf num2 <> 1 Then
Print "outside"
End If
End If
'-------------------------------------------
'mouse 右點一下菱形線不見 -
' 再點一下菱形線出現 -
'-------------------------------------------
If (Button = 2) Then
num2 = num2 + 1
Line (xpt(2), ypt(2))-(xpt(1), ypt(1)), white, B
If num2 = 2 Then
Line (xpt(2), ypt(2))-(xpt(1), ypt(1)), red, B
num2 = 0
End If
End If
End Sub