请问这段代码中的错误是怎么回事,谢谢
目的是读取一条直线的起点终点坐标,调试的时候说类型不配,就是倒数第二句,谢谢指点。Private Sub CommandButton1_Click()<BR> Dim startPoint As Variant<BR> Dim endPoint As Variant<BR> Dim objName As String<BR> Dim entry As AcadEntity<BR> For Each entry In ThisDrawing.ModelSpace<BR> objName = entry.ObjectName<BR> If objName = "acadline" Then<BR> startPoint = entry.startPoint<BR> endPoint = entry.endPoint<BR> End If<BR> Next<BR>MsgBox "This ellipse has a start point of " & startPoint(0) & ", " & startPoint(1) & ", " &_ startPoint(2) & " and an endpoint of " & endPoint(0) & ", " & endPoint(1) & ", " &_ endPoint(2), vbInformation, "StartPoint Example"<BR>End Sub 应该是If objName = "AcDbLine" Then吧。 hehe~~那是有问题
不过 说这句也不对
MsgBox "This ellipse has a start point of " & startPoint(0) & ", " & startPoint(1) & ", " & startPoint(2) & " and an endpoint of " & endPoint(0) & ", " & endPoint(1) & ", " & endPoint(2), vbInformation, "StartPoint Example"
提示 类型不匹配 类型不匹配是因为你的图形中没有直线吧。
所以显示部分应该也放到判断语句中。
页:
[1]