隆多假动作上篮:[分享]慎用On Error Resume Next错误陷井
来源:百度文库 编辑:九乡新闻网 时间:2024/05/03 06:06:16
在编程时,经常使用错误陷井技术(On Error Resume Next),以下就是一段例子:
On Error Resume Next '利用错误陷井
Sheets("data").Cells.Delete '先对DATA工作表清空,如果已经存在工作表DATA,就不会报错
If Err.Number <> 0 Then '如果出错,说明DATA工作表不存在
Sheets.Add.Name = "DATA" '那么就自动添加一个工作表,并命名为DATA
Err.Clear'清除错误标记,
On Error GoTo 0'恢复系统默认错误处理
End If
其实,一般情况下是可行的,因为VBE默认的错误捕获方式是图示的绿色方框标识的“遇到未处理的错误时中断”。
但是,一旦将错误捕获方式修改成图示的红色方框标识的“发生错误则中断”时,再想利用错误陷井,你就会被拒之门外了!因为系统一遇到就中断,不会忽略过去,所以,以上代码运行时,如果DATA工作表不存在,代码就始终无法按你预期的那样自动往下执行!
[分享]慎用On Error Resume Next错误陷井
On Error Resume Next:VBscript错误处理
on error resume next
on error resume next用法
on error resume next 用法
关于on error resume next滥用
on error resume next的滥用
关于 on error resume next 的一些笔记
vbScript on error resume next容错使用心得
n Error Resume Next是什么意思
vc++6.0中Error spawning cl.exe错误的解决方法
IIS 7 HTTP 错误 500.19 - Internal Server Error解决方法
The DBMS returned an unspecified error错误解决方案
China to focus on people's livelihood in next five years: minister
分享:LIBCD.lib(crt0.obj) : error LNK2001: unres...
ERROR 2003:Can't connect to MySQL server on 'localhost' (10061) mysql
【resume template】
丢失Android系统库或者Conversion to Dalvik format failed with error 1错误的解决
magento 1.4 There has been an error processing your request 错误
Windows核心编程(第五版)笔记 第一章 错误处理(Error Handling)
next是什么意思
关于在tomcat下配置 error-page 500错误不能在IE下转发页面的问题
Interview & Resume tips
【resume】--- self - evaluation