乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 248|回复: 13

调试错误(参数不正确)

[复制链接]

194

主题

592

帖子

11

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1380
发表于 2006-10-16 14:06:17 | 显示全部楼层 |阅读模式
让我看看能不能解释一下。我有一个功能
  1. Public Function PointTest(Pt As Long) As Boolean
  2.    
  3.     If getCivilObjects = False Then
  4.         Exit Function
  5.     End If
  6.    
  7.     Dim oPoint As AeccPoint
  8.    
  9.     Set oPoint = AllPoints.Find(Pt)  <== debug stops here, value of 'oPoint' is "Nothing"
  10.    
  11.     If oPoint Is Nothing Then
  12.         MsgBox "point not found"
  13.     End If
如果我使用有效的点编号(dwg中的一个)运行,它可以正常工作'oPoint#039;是一个对象(aeccpoint)。如果使用无效点运行它,则会出现调试错误&引用;参数不正确
从文件中
此时I#039;我完全糊涂了
谢谢
回复

使用道具 举报

194

主题

592

帖子

11

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1380
发表于 2006-10-16 14:22:33 | 显示全部楼层
“The”;“本地人”;对话框包含此信息
回复

使用道具 举报

71

主题

928

帖子

8

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1230
发表于 2006-10-16 14:47:34 | 显示全部楼层
您只需要知道,如果点不存在,Find方法会抛出错误,并为其设置plqan。这里是#039;这是我的PackPoints宏中的一个片段,它正是这样做的:
  1. On Error Resume Next
  2. For I = iStPnt To iEndPnt
  3.     Set oPoint = cPoints.Find(I)
  4.     If Err.Number = 0 Then
  5.         If oPoint.Number = iStPnt Then
  6.             iStPnt = iStPnt + 1
  7.         Else
  8.             J = J + 1
  9.             lPnts(J) = I
  10.         End If
  11.     Else
  12.         Err.Clear 'just clear the error, I need not do anything with it
  13.     End If
  14. Next I
现在,我知道有些人更喜欢将错误发送给错误处理程序,但在这种情况下,我只希望将其在线处理,因为这是这段代码中唯一可能出现的错误。
回复

使用道具 举报

10

主题

86

帖子

5

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
126
发表于 2006-10-16 14:54:33 | 显示全部楼层
马克,除非你想要学习体验,否则在你投入大量时间之前,你可能想查看Civil 3D提供的查询&nbsp;我有一个屏幕截图附加,但它是大的方式-一个非常漂亮的工具!
回复

使用道具 举报

194

主题

592

帖子

11

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1380
发表于 2006-10-16 15:02:16 | 显示全部楼层

谢谢杰夫。
回复

使用道具 举报

194

主题

592

帖子

11

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1380
发表于 2006-10-16 15:10:11 | 显示全部楼层

实际上是&#039;这就是为什么我&#039;我在写这个应用程序&nbsp;我确实试过了,但它&#039;对我来说,这是一种放慢速度的方法,对我来说是一种很好的方法。我真的很想学习VBA,那就是&#039;这就是为什么我&#039;我正在写这个应用程序
谢谢史蒂夫。
回复

使用道具 举报

194

主题

592

帖子

11

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1380
发表于 2006-10-16 15:21:41 | 显示全部楼层
查看一些示例代码和文档,他们似乎希望您使用;ContainsPoint方法“;在“中”;AeccPointGroup
回复

使用道具 举报

194

主题

592

帖子

11

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1380
发表于 2006-10-16 15:49:18 | 显示全部楼层
这是可行的
  1. Public Function GroupsTest()
  2.     If getCivilObjects = False Then
  3.         GroupsTest = False
  4.         Exit Function
  5.     End If
  6.    
  7.     Dim oGroups As AeccPointGroups
  8.     Set oGroups = AeccDoc.PointGroups
  9.    
  10.     Dim oGroup As AeccPointGroup
  11.     Set oGroup = oGroups.Item("_All Points")
  12.    
  13.     If oGroup.ContainsPoint(9999) Then '9999 is not in the dwg
  14.         GroupsTest = True
  15.     Else
  16.         MsgBox "point not found"
  17.     End If
  18.    
  19. End Function
回复

使用道具 举报

71

主题

928

帖子

8

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1230
发表于 2006-10-16 16:15:09 | 显示全部楼层
虽然这肯定是该方法的一个用途,但在我看来,如果你不首先与团队合作,这似乎是一种耗时的消遣。(如果你只是在点之间反转,你就不会这样做。)
只要确定Find(pt)是否抛出错误,就可以在不访问组/组的情况下执行相同的操作。由于无论如何都需要使用Find(pt)来访问点#039;s属性。。。。。。。
回复

使用道具 举报

194

主题

592

帖子

11

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1380
发表于 2006-10-16 17:49:38 | 显示全部楼层
马克,你喜欢这份工作吗
这是一个我通常使用的错误处理程序示例:
  1. Public Function PointTest(Pt As Long) As Boolean
  2.     On Error Goto ErrorHandler
  3.        
  4.     If getCivilObjects = False Then
  5.         Exit Function
  6.     End If
  7.    
  8.     Dim oPoint As AeccPoint
  9.    
  10.     Set oPoint = AllPoints.Find(Pt)  'Need to catch the error number that was thrown here.
  11.    
  12.     If oPoint Is Nothing Then
  13.         MsgBox "point not found"
  14.     End If
  15.        
  16.         'bunch of stuff here
  17. ExitHere:
  18.         'clean up any references...
  19.         set oPoint = nothing
  20.        
  21.        
  22.         exit function
  23. ErrorHandler:
  24.         select case Err.number
  25.         case -22222 '<-This would be where the error that is thrown from the .Find method
  26.                 resume next 'resume on the line following where the error was thrown
  27.         case else
  28.                 msgbox "Something just happened..."
  29.         end select
  30.        
  31.         resume ExitHere
  32. end function
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-7-6 21:07 , Processed in 0.582221 second(s), 72 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表