请问这段代码中的错误是怎么回事,谢谢
目的是读取一条直线的起点终点坐标,调试的时候说类型不配,就是倒数第二句,谢谢指点。Private Sub CommandButton1_Click()
Dim startPoint As Variant
Dim endPoint As Variant
Dim objName As String
Dim entry As AcadEntity
For Each entry In ThisDrawing.ModelSpace
objName = entry.ObjectName
If objName = "acadline" Then
startPoint = entry.startPoint
endPoint = entry.endPoint
End If
Next
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"
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]