乐筑天下

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

Question 18 answers go here

[复制链接]

194

主题

592

帖子

11

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1380
发表于 2005-8-25 20:07:38 | 显示全部楼层 |阅读模式
回复

使用道具 举报

116

主题

996

帖子

9

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1466
发表于 2005-8-25 20:14:33 | 显示全部楼层
... to allow the programmer to employ poor coding habits.
Just kidding, sometime that's a perfectly valid route to go.
:)
回复

使用道具 举报

116

主题

996

帖子

9

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1466
发表于 2005-8-25 20:33:43 | 显示全部楼层
I thought it was to repair the damage done from having to type the word Dim a coupla hundred times a day.
I'll probably get dropped under a camel for that ..
回复

使用道具 举报

154

主题

1274

帖子

8

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1936
发表于 2005-8-25 20:39:08 | 显示全部楼层

  1. Dim filehandle As Integer, _
  2.     nullheader As String * 7, _
  3.     stream     As String, _
  4.     rawRecord  As RawRecordType, _
  5.     i          As Long

回复

使用道具 举报

154

主题

1274

帖子

8

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1936
发表于 2005-8-25 20:48:59 | 显示全部楼层


                               
登录/注册后可看大图

回复

使用道具 举报

61

主题

792

帖子

35

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1015
发表于 2005-8-25 21:24:18 | 显示全部楼层


                               
登录/注册后可看大图

回复

使用道具 举报

116

主题

996

帖子

9

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1466
发表于 2005-8-25 21:53:00 | 显示全部楼层

In most cases that is indeed the reason ...
However ... it can actually be a very handy tool if used properly ...
Consider a loop that does series of tasks (or even a single task) on a group of objects. We are all familiar with the "For Next" loops ...or at least most of us are ...
It is my understanding (and I am frequently wrong) that this error handler allows you to skip over the items causing this error within the loop ...
example
  1. CharCode = 32
  2. On Error Resume Next
  3. For X = -127 to 127
  4.   MsgBox CharCode / X
  5. Next X

Now while the point of this exercise might be pointless, it will catch the divide by zero error that will be generated when X = 0, thus the loop will continue to execute until it is finished.
Now for an example of how it can be used for the lazy programmer ...
  1. Set ThisSSet = ThisDrawing.SelectionSets.Add("NewSSet")
  2. ThisSSet.SelectOnScreen
  3. On Error Resume Next
  4. For Each ACBlock in ThisSSet
  5.   MsgBox ACBlock.Name & vbCr & _
  6.               "X:" & ACBlock.XScaleFactor & vbCr & _
  7.               "Y:" & ACBlock.YScaleFactor & vbCr & _
  8.               "Z:" & ACBlock.ZScaleFactor
  9. Next ACBlock

Now what happens is if there is an object that is not a block it will generate an error because of the properties being read and the error handler will do it's job. This is an example of lazy programming as the user could have programmed in a filter to allow for only the selection of blocks. Plus what happens when the function encounters a block that has had the name stripped from the drawing database as in some of the older CadLock drawings.
BUT
If you call another subroutine without an error handler AFTER you use the Resume Next handler, if the called function has an error it will be a pain in the butt to find it because the function will work as though nothing is wrong ... been there done that ... learned the hard way
回复

使用道具 举报

154

主题

1274

帖子

8

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1936
发表于 2005-8-26 05:08:23 | 显示全部楼层
Specifies that when a run-time error occurs, control goes to the statement immediately following the statement where the error occurred where execution continues... Sample:
  1. Public Function MeSelectionSet(SetNme As String) As AcadSelectionSet
  2.   On Error Resume Next
  3.   
  4.   With ThisDrawing.SelectionSets
  5.     Set MeSelectionSet = .Add(SetNme)
  6.     If Err.Number  0 Then
  7.       Err.Clear
  8.       .Item(SetNme).Delete
  9.       Set MeSelectionSet = .Add(SetNme)
  10.     End If
  11.   End With
  12.   
  13. End Function
回复

使用道具 举报

116

主题

996

帖子

9

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1466
发表于 2005-8-26 10:51:29 | 显示全部楼层
on error resume next is error avoidance not error handling...
try
catch ex as exception
finally 'optional
end try
is error handling.
回复

使用道具 举报

154

主题

1274

帖子

8

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1936
发表于 2005-8-26 11:14:56 | 显示全部楼层
My guess C++...
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-7-4 09:40 , Processed in 0.294500 second(s), 73 queries .

© 2020-2025 乐筑天下

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