wlh9421 发表于 2008-10-25 01:24:00

运行时错误‘13’ -类型不匹配

<p>Public Sub creatcircle()<br/>Dim centerpoint(0 To 2) As Double<br/>setpoint3d centpoint, 0, 0, 0<br/>Dim mspace As New clsModelSpace<br/>mspace.AddCircle centerpoint, 50<br/>Dim startpoint(0 To 2) As Double, endpoint(0 To 2) As Double<br/>setpoint3d startpoint, 50, 0, 0<br/>setpoint3d endpoint, 150, 0, 0<br/>mspace.AddCircleBy2Point startpoint, endpoint</p><p>End Sub</p><p>Public Function setpoint3d(ByVal point As Variant, ByVal x As Double, ByVal y As Double, ByVal z As Double)<br/><font color="#f70909">Debug.Assert (VarType(point) = vbArray + vbDouble)----------------------------错误地方!!!!!!!!!!!!!!</font><br/>Debug.Assert (LBound(point) = 0 And UBound(point) = 2)<br/>point(0) = x<br/>point(1) = y<br/>point(2) = z<br/>End Function</p><p>Public Function GetDistanceBetween2Point(ByVal startpoint As Variant, ByVal endpoint As Variant) As Double<br/>Dim a As Double, b As Double, c As Double<br/>x = startpoint(0) - endpoint(0)<br/>y = startpoint(1) - endpoint(1)<br/>z = startpoint(2) - endpoint(2)<br/>GetDistanceBetween2Point = Sqr(x ^ 2 + y ^ 2 + z ^ 2)<br/>End Function</p><p>Public Function GetMiddlePointBetween2Point(ByVal startpoint As Variant, ByVal endpoint As Variant) As Double<br/>Dim midpoint(0 To 2) As Double<br/>midpoint(0) = (startpoint(0) - endpoint(0)) / 2<br/>midpoint(1) = (startpoint(1) - endpoint(1)) / 2<br/>midpoint(2) = (startpoint(2) - endpoint(2)) / 2<br/>GetMiddlePointBetween2Point = midpoint<br/>End Function</p><p>Public Function AddCircle(ByVal centerpoint As Variant, ByVal radius As Double) As AcadCircle<br/>Debug.Assert (radius &gt; 0.0000001)<br/>Debug.Assert (VarType(centerpoint) = vbArray + vbDouble)<br/>Set AddCircle = ThisDrawing.ModelSpace.AddCircle(centerpoint, radius)<br/>End Function</p><p>Public Function AddCircleBy2Point(ByVal startpoint As Variant, ByVal endpoint As Variant) As AcadCircle<br/>Debug.Assert (VarType(startpoint) = vbArray + vbDouble)<br/>Debug.Assert (VarType(endpoint) = vbArray + vbDouble)<br/>'计算圆心和半径<br/>Dim centerpoint As Variant, radius As Double<br/>centerpoint = math.GetMiddlePointBetween2Point(startpoint, endpoint)<br/>radius = math.GetDistanceBetween2Point(startpoint, endpoint) / 2<br/>Set AddCircleBy2Point = AddCircle(centerpoint, radius)<br/>End Function<br/></p><p></p>
页: [1]
查看完整版本: 运行时错误‘13’ -类型不匹配