fmfm 发表于 2004-3-28 14:52:00

请问这段代码中的错误是怎么回事,谢谢

目的是读取一条直线的起点终点坐标,调试的时候说类型不配,就是倒数第二句,谢谢指点。


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 " &amp; startPoint(0) &amp; ", " &amp; startPoint(1) &amp; ", " &amp;_ startPoint(2) &amp; " and an endpoint of " &amp; endPoint(0) &amp; ", " &amp; endPoint(1) &amp; ", " &amp;_ endPoint(2), vbInformation, "StartPoint Example"<BR>End Sub

efan2000 发表于 2004-3-28 17:23:00

应该是If objName = "AcDbLine" Then吧。

fmfm 发表于 2004-3-28 19:00:00

hehe~~那是有问题


不过 说这句也不对


MsgBox "This ellipse has a start point of " &amp; startPoint(0) &amp; ", " &amp; startPoint(1) &amp; ", " &amp; startPoint(2) &amp; " and an endpoint of " &amp; endPoint(0) &amp; ", " &amp; endPoint(1) &amp; ", " &amp; endPoint(2), vbInformation, "StartPoint Example"


       


提示 类型不匹配

mccad 发表于 2004-3-28 19:42:00

类型不匹配是因为你的图形中没有直线吧。


所以显示部分应该也放到判断语句中。
页: [1]
查看完整版本: 请问这段代码中的错误是怎么回事,谢谢