xinghesnak 发表于 2006-5-10 08:07:00

那你就在点击时间末尾把三个text控件清空不就行了。。。何必非得卸载窗体呢。。。

dchlmz 发表于 2006-5-10 08:26:00

<P>试试下面的,应该没问题</P>
<P>Option Explicit<BR>Private Type POINTAPI<BR>x As Double<BR>y As Double<BR>z As Double<BR>End Type<BR>Dim p() As POINTAPI</P>
<P>&nbsp;</P>
<P>&nbsp;</P>
<P>Private Sub UserForm_Initialize()<BR>ReDim p(0) As POINTAPI<BR>End Sub</P>
<P><BR>Private Sub CommandButton1_Click()<BR>&nbsp;&nbsp;&nbsp; ' 确保文本框的值不为空<BR>&nbsp;&nbsp;&nbsp; Dim item As MSForms.Control<BR>&nbsp;&nbsp;&nbsp; For Each item In UserForm1.Controls<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If TypeOf item Is TextBox Then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If Len(item.Text) = 0 Then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MsgBox "请输入定位点!", vbCritical<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Exit Sub<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<BR>&nbsp;&nbsp;&nbsp; Next item<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; '存点<BR>&nbsp;&nbsp; If p(0).x &lt;&gt; 0 Then ReDim Preserve p(UBound(p) + 1)</P>
<P>&nbsp;&nbsp; p(UBound(p)).x = Val(TextBox1.Text)<BR>&nbsp;&nbsp; p(UBound(p)).y = Val(TextBox2.Text)<BR>&nbsp;&nbsp; p(UBound(p)).z = Val(TextBox3.Text)</P>
<P>&nbsp;&nbsp; TextBox1.Text = ""<BR>&nbsp;&nbsp; TextBox2.Text = ""<BR>&nbsp;&nbsp; TextBox3.Text = ""<BR>&nbsp; </P>
<P><BR>End Sub</P>
<P>&nbsp;</P>
<P>Private Sub CommandButton2_Click()<BR>&nbsp;&nbsp;&nbsp; ' 确保文本框的值不为空<BR>&nbsp;&nbsp;&nbsp; Dim item As MSForms.Control<BR>&nbsp;&nbsp;&nbsp; For Each item In UserForm1.Controls<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If TypeOf item Is TextBox Then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If Len(item.Text) = 0 Then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MsgBox "请输入定位点!", vbCritical<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Exit Sub<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<BR>&nbsp;&nbsp;&nbsp; Next item<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; '存点<BR>&nbsp;&nbsp; If p(0).x &lt;&gt; 0 Then ReDim Preserve p(UBound(p) + 1)</P>
<P>&nbsp;&nbsp; p(UBound(p)).x = Val(TextBox1.Text)<BR>&nbsp;&nbsp; p(UBound(p)).y = Val(TextBox2.Text)<BR>&nbsp;&nbsp; p(UBound(p)).z = Val(TextBox3.Text)<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; ' 绘制直线<BR>&nbsp;&nbsp;&nbsp; Dim i As Integer<BR>&nbsp;&nbsp;&nbsp; Dim FormPnt(0 To 2) As Double<BR>&nbsp;&nbsp;&nbsp; Dim ToPnt(0 To 2) As Double<BR>&nbsp;&nbsp;&nbsp; For i = 1 To UBound(p)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FormPnt(0) = p(i - 1).x<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FormPnt(1) = p(i - 1).y<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FormPnt(2) = p(i - 1).z<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ToPnt(0) = p(i).x<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ToPnt(1) = p(i).y<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ToPnt(2) = p(i).z<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ThisDrawing.ModelSpace.AddLine FormPnt, ToPnt<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; Next<BR>&nbsp;&nbsp;&nbsp; End&nbsp;&nbsp; '结束程序<BR>End Sub</P>

xinghesnak 发表于 2006-5-10 08:49:00

<P>其实你的程序总体是对的,要注意两点:</P>
<P>一。程序中这一段</P>
<P>For i = 2 To UBound(p)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FormPnt(0) = p(i - 1).x<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FormPnt(1) = p(i - 1).y<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FormPnt(2) = p(i - 1).z<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ToPnt(0) = p(i).x<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ToPnt(1) = p(i).y<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ToPnt(2) = p(i).z<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ThisDrawing.ModelSpace.AddLine FormPnt, ToPnt<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; Next</P>
<P>让人很费解,为什么i要从2开始递增呢?是不是你想连续画线,那就应该改成这样</P>
<P>For i =&nbsp;1 To UBound(p)&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FormPnt(0) = p(i -1).x<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FormPnt(1) = p(i -1).y<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FormPnt(2) = p(i -1).z<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ToPnt(0) = p(i).x<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ToPnt(1) = p(i).y<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ToPnt(2) = p(i).z<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ThisDrawing.ModelSpace.AddLine FormPnt, ToPnt<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; Next</P>
<P>就是把2改成1就行了,哈哈!</P>
<P>二,我给你的这句话有问题</P>
<P>If p(0).x &lt;&gt; 0 Then ReDim Preserve p(UBound(p) + 1)</P>
<P>如果textbox1控件真的输入0,后面就画不出来了。再增加一个变量,判断是不是第一次输入数值(因为P(0)的xyz都有默认值0)是第一次,就直接</P>
<P>p(UBound(p)).x = Val(TextBox1.Text)<BR>&nbsp;&nbsp; p(UBound(p)).y = Val(TextBox2.Text)<BR>&nbsp;&nbsp; p(UBound(p)).z = Val(TextBox3.Text)</P>
<P>不是就先ReDim Preserve p(UBound(p) + 1),这个改动很重要!</P>

singlegu 发表于 2006-5-10 16:41:00

<P>呵呵,我的程序搞好了,谢谢各位大虾的帮忙</P>
<P>这是正确的程序,哪位新手想看也能参考</P>
<P>Option Explicit<BR>Private Type POINTAPI<BR>x As Double<BR>y As Double<BR>z As Double<BR>End Type<BR>Dim p() As POINTAPI</P>
<P><BR>Private Sub UserForm_Initialize()<BR>ReDim p(0) As POINTAPI<BR>End Sub</P>
<P><BR>Private Sub CommandButton1_Click()<BR>&nbsp;&nbsp;&nbsp; ' 确保文本框的值不为空<BR>&nbsp;&nbsp;&nbsp; Dim item As MSForms.Control<BR>&nbsp;&nbsp;&nbsp; For Each item In UserForm1.Controls<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If TypeOf item Is TextBox Then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If Len(item.Text) = 0 Then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MsgBox "请输入定位点!", vbCritical<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Exit Sub<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<BR>&nbsp;&nbsp;&nbsp; Next item<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; TextBox1.SetFocus = 1<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; '存点<BR>&nbsp;&nbsp; </P>
<P>&nbsp;&nbsp; p(UBound(p)).x = Val(TextBox1.Text)<BR>&nbsp;&nbsp; p(UBound(p)).y = Val(TextBox2.Text)<BR>&nbsp;&nbsp; p(UBound(p)).z = Val(TextBox3.Text)<BR>&nbsp;&nbsp; <BR>&nbsp;&nbsp; ReDim Preserve p(UBound(p) + 1)</P>
<P>&nbsp;&nbsp; TextBox1.Text = ""<BR>&nbsp;&nbsp; TextBox2.Text = ""<BR>&nbsp;&nbsp; TextBox3.Text = ""<BR>&nbsp;&nbsp; </P>
<P>End Sub</P>
<P>&nbsp;</P>
<P>Private Sub CommandButton2_Click()<BR>&nbsp;&nbsp;&nbsp; ' 确保文本框的值不为空<BR>&nbsp;&nbsp;&nbsp; Dim item As MSForms.Control<BR>&nbsp;&nbsp;&nbsp; For Each item In UserForm1.Controls<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If TypeOf item Is TextBox Then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If Len(item.Text) = 0 Then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MsgBox "请输入定位点!", vbCritical<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Exit Sub<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<BR>&nbsp;&nbsp;&nbsp; Next item<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp; '存点<BR>&nbsp;&nbsp; p(UBound(p)).x = Val(TextBox1.Text)<BR>&nbsp;&nbsp; p(UBound(p)).y = Val(TextBox2.Text)<BR>&nbsp;&nbsp; p(UBound(p)).z = Val(TextBox3.Text)<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; ' 绘制直线<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; Dim i As Integer<BR>&nbsp;&nbsp;&nbsp; Dim FormPnt(0 To 2) As Double<BR>&nbsp;&nbsp;&nbsp; Dim ToPnt(0 To 2) As Double<BR>&nbsp;&nbsp;&nbsp; For i = 1 To UBound(p)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FormPnt(0) = p(i - 1).x<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FormPnt(1) = p(i - 1).y<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FormPnt(2) = p(i - 1).z<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ToPnt(0) = p(i).x<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ToPnt(1) = p(i).y<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ToPnt(2) = p(i).z<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ThisDrawing.ModelSpace.AddLine FormPnt, ToPnt<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; Next i<BR>&nbsp;&nbsp;&nbsp; End&nbsp;&nbsp; '结束程序<BR>End Sub</P>
<P>&nbsp;</P>

dance 发表于 2006-5-12 22:20:00

[求助]能帮我也看看有什么问题吗

xinghesnak发表于2006-5-8 15:32:00static/image/common/back.gif
看到最下面的那句
Private Sub Form_Load()ReDim PointData(0) As userDataEnd Sub
了吗?一定要写上,要不就下标越...


<P>我在编一个求点集凸包的程序</P>
<P>采点集的程序部分已经搞定了但到了去极点部分就老提示下标越界</P>
<P>下面是我的程序:</P>
<P>Option Explicit<BR>Private Type pointinfo<BR>x As Single&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '点的x 坐标值<BR>y As Single&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '点的y 坐标值<BR>q As Single&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '与水平线的夹角<BR>End Type<BR>Dim p0 As pointinfo<BR>Dim p(1 To 200) As pointinfo&nbsp;&nbsp;&nbsp; '点集<BR>Dim ps(1 To 200) As pointinfo&nbsp;&nbsp;&nbsp; '排序后的点集<BR>Dim pi(1 To 200) As pointinfo&nbsp;&nbsp; '极点<BR>Dim n, m, d As Integer<BR>Dim x0, y0 As Single<BR>Dim l, e As Integer</P>
<P>Private Sub Form_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)<BR>DrawWidth = 4<BR>If n = 0 Then<BR>&nbsp;p0.x = x<BR>&nbsp;p0.y = y<BR>&nbsp;Circle (x, y), 100, RGB(255, 0, 255)<BR>Else '输入点集<BR>&nbsp;p(n).x = x<BR>&nbsp;p(n).y = y<BR>&nbsp;Circle (x, y), 10, RGB(255, 255, 0)<BR>End If<BR>n = n + 1<BR>x0 = x<BR>y0 = y</P>
<P>End Sub</P>
<P><BR>Private Sub Command2_Click()<BR>Dim i As Integer<BR>Dim q As Single<BR>p(n).x = x0<BR>p(n).y = y0<BR>Const pi = 3.14<BR>For i = l To n<BR><B>If p(i).y - p0.y = 0 Then</B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (总是在这句提示下标越界)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If p(i).x - p0.x = 0 Then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; p(i).q = 90<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ElseIf p(i).x - p0.x &gt; 0 Then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; p(i).q = 180 / pi * Atn((p(i).y - p0.y) / (p(i).x - p0.x))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Else<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; p(i).q = 180 / pi * Atn((p(i).y - p0.y) / (p(i).x - p0.x)) + 180<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<BR>ElseIf p(i).y - p0.y &lt; 0 Then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If p(i).x - p0.x = 0 Then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; p(i).q = 270<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ElseIf p(i).x - p0.x &gt; 0 Then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; p(i).q = 360 + 180 / pi * Atn((p(i).y - p0.y) / (p(i).x - p0.x))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Else<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; p(i).q = 180 + 180 / pi * Atn((p(i).y - p0.y) / (p(i).x - p0.x))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<BR>End If<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>Next i</P>
<P>End Sub</P><BR>

xinghesnak 发表于 2006-5-13 08:31:00

<P>楼上的,你的数组下标定义的是1到200,而你的n是0,所以越界了。。定义你的数组时用</P>
<P>Dim p(0 To 200) As pointinfo&nbsp;&nbsp;Dim ps(0 To 200) As pointinfo&nbsp;&nbsp;Dim pi(0 To 200) As pointinfo</P>
<P>就行了。。</P>

dance 发表于 2006-5-13 22:06:00

[求助]太感谢了

xinghesnak发表于2006-5-13 8:31:00static/image/common/back.gif
楼上的,你的数组下标定义的是1到200,而你的n是0,所以越界了。。定义你的数组时用
Dim p(0 To 200) As pointinfo Dim ps(0 To ...

<BR>
<P>呵呵我是新手多谢指教!太感谢了!</P>
<P>但现在又出现新问题了。(注:我又把程序稍改了下,从p(0)开始记录点)</P>
<P>我想把点集中y最近小且距x最远的点找到,就用二分法排了序,但数组p()的值纵传不到数组pl()上。请在帮忙看下:</P>
<P>Option Explicit<BR>Private Type pointinfo<BR>x As Single&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '点的x 坐标值<BR>y As Single&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '点的y 坐标值<BR>q As Single&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '与水平线的夹角<BR>End Type<BR>Dim p0 As pointinfo<BR>Dim p(0 To 200) As pointinfo&nbsp;&nbsp;&nbsp; '点集<BR>Dim pl(0 To 200) As pointinfo&nbsp;&nbsp; '求出起始点<BR>Dim ps(0 To 200) As pointinfo&nbsp;&nbsp; '排序后的点集<BR>Dim pi(0 To 200) As pointinfo&nbsp;&nbsp; '极点<BR>Dim n, m, d As Integer<BR>Dim x0, y0 As Single<BR>Dim l, e As Integer</P>
<P>Private Sub Form_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)<BR>DrawWidth = 4<BR>If n = 0 Then<BR>&nbsp;p(0).x = x<BR>&nbsp;p(0).y = y<BR>&nbsp;Circle (x, y), 100, RGB(255, 0, 255)<BR>Else '输入点集<BR>&nbsp;p(n).x = x<BR>&nbsp;p(n).y = y<BR>&nbsp;Circle (x, y), 10, RGB(255, 255, 0)<BR>End If<BR>n = n + 1<BR>x0 = x<BR>y0 = y<BR>&nbsp;<BR>End Sub</P>
<P>Private Sub Command2_Click()<BR>Dim i As Integer<BR>Dim q As Single<BR>p(n).x = x0<BR>p(n).y = y0<BR>Const pi = 3.14<BR>Dim u, j As Integer<BR>Dim k, r, f As Integer<BR>Dim term As pointinfo<BR>For u = 0 To n<BR>&nbsp; term = p(l)<BR>&nbsp; k = 0<BR>&nbsp; r = u - 0<BR>&nbsp; Do While k &lt;= r<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; f = Int((k + r) / 2)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If term.y &lt; pl(f).y Or (term.y = pl(f).y And (Abs(term.x) &gt; Abs(pl(f).x))) Then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; r = f - 1<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Else<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; k = f + 1<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<BR>&nbsp; Loop<BR>&nbsp; For j = u - 1 To k Step -1<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pl(j + 1) = pl(j)<BR>&nbsp; Next j<BR>&nbsp; pl(k) = term<BR>Next u<BR></P>

dance 发表于 2006-5-14 22:24:00

[求助]大侠今天出门了?

<P>大侠今天出门了?</P>
<P>有空时,请赐教</P>
<P>多谢</P>

dance 发表于 2006-5-14 22:29:00

[求助]

dance发表于2006-5-14 22:24:00static/image/common/back.gif回复:(dance)大侠今天出门了?
大侠今天出门了?
有空时,请赐教
多谢

<BR>我重创个帖子
页: 1 2 [3]
查看完整版本: 小女子跪求各位大虾