[求助]关于画四边形的问题
我设计一个画四边形的程序,输入四点坐标可在图片框中画出一个四边形,可是出现一个问题:当输入的点的坐标不合适时会出现两条边相交问题,也就不成四边形了,我不知道应该怎么解决这个问题,来避免出现这个问题。希望各位高手指导一下,谢谢!程序如下:
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Picture1.PSet (X, Y) '绘制四边形形的四个顶点,并把各顶点坐标显示在相应的文本框里
If i = 4 Then i = 0
Select Case i
Case 0
Text1.Text = X
Text2.Text = Y
Case 1
Text3.Text = X
Text4.Text = Y
Case 2
Text5.Text = X
Text6.Text = Y
Case 3
Text14.Text = X
Text15.Text = Y
Picture1.Cls
x1 = Val(Text1.Text)
y1 = Val(Text2.Text)
x2 = Val(Text3.Text)
y2 = Val(Text4.Text)
x3 = Val(Text5.Text)
y3 = Val(Text6.Text)
x4 = Val(Text7.Text)
y4 = Val(Text8.Text)
Picture1.ForeColor = RGB(0, 0, 0)
Picture1.Line (x1, y1)-(x2, y2)
Picture1.Line (x2, y2)-(x3, y3)
Picture1.Line (x3, y3)-(x4, y4)
Picture1.Line (x1, y1)-(x4, y4)
Picture1.CurrentX = x4
Picture1.CurrentY = y4 + 150
Picture1.Print "初始图"
End Select
i = i + 1
End Sub