(求助)请帮我看一下这段代码为什么不行?
<P>本人初学VBA,请各位多多指教,这段代码为什么不行</P><P>找到实体层中各直线的交点,并把它们打印出来.</P>
<P> Sub findpoint()<BR>Dim newlayer As AcadLayer<BR>Dim intpoints As Variant<BR>Set newlayer = ThisDrawing.Layers("实体层")<BR>ThisDrawing.ActiveLayer = newlayer<BR>For Each lineobj1 In ThisDrawing.ModelSpace<BR> For Each lineobj2 In ThisDrawing.ModelSpace<BR> If lineobj1.ObjectID <> lineobj2.ObjectID Then<BR> intpoints = lineobj1.IntersectWith(lineobj2.acExtendNone)<BR> End If<BR> Next<BR>Next<BR>Dim i As Integer, j As Integer, k As Integer<BR>Dim str As String</P>
<P>If VarType(intpoints) <> vbEmpty Then<BR> For i = LBound(intpoints) To UBound(intpoints)<BR> str = "Intersection Point[" & k & "] is: " & intpoints(j) & "," & intpoints(j + 1) & "," & intpoints(j + 2)<BR> MsgBox str, , "IntersectWith Example"<BR> str = ""<BR> i = i + 2<BR> j = j + 3<BR> k = k + 1<BR> Next<BR> End If<BR>End Sub<BR> 谢谢大家了</P> <P>问题出在这里:</P>
<P>If lineobj1.ObjectID <> lineobj2.ObjectID Then<BR> intpoints = lineobj1.IntersectWith(lineobj2.acExtendNone)<BR> End If<BR>lineobj2.acExtendNone,该是“lineobj2,acExtendNone”而不是一个“.”</P> <P>太感谢你了,都是我马虎造成的,给大家添麻烦了</P>
页:
[1]