明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1430|回复: 3

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

[复制链接]
发表于 2004-3-28 14:52:00 | 显示全部楼层 |阅读模式
目的是读取一条直线的起点终点坐标,调试的时候说类型不配,就是倒数第二句,谢谢指点。 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
发表于 2004-3-28 17:23:00 | 显示全部楼层
应该是If objName = "AcDbLine" Then吧。
 楼主| 发表于 2004-3-28 19:00:00 | 显示全部楼层
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"


       


提示 类型不匹配
发表于 2004-3-28 19:42:00 | 显示全部楼层
类型不匹配是因为你的图形中没有直线吧。


所以显示部分应该也放到判断语句中。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-28 08:25 , Processed in 0.168419 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表