this catches the error code and the description of the error and writes to the log file. However, the problem is that the code after we caught the error, if the error occurs again and you don’t catch it, the code will still ignore the error and continue to run. Ignoring errors is an undesirable result and can make debugging difficult. At this point, the sentence “On Error GoTo 0” can be used to terminate the previous Error handling, that is, it can be paired with “On Error Resume Next”. This will not affect the rest of the code.
has several characteristics to understand,
, 1 on error resume Next if defined in the global, the effect is global, you use this phrase in the main program, the back if the call a function, so if there is an error in the function, also will be ignored, behind the function call statements in your main program can also capture the error, this can be through the following simple code validation:
The result of executing the above code:
13 – type が consistent し ま せ ん.
main ….
As you can see, aaaaaaaaaaa was a deliberate error in the function, followed by wscript.echo “Funcb OK” and the following code were not executed. However, wscript.echo “main…” in the main program The statement is executed. That is, if a statement in a function is wrong, none of the subsequent statements in the function are executed, and the statement following the call to the function is executed directly.
2, On Error Resume Next If defined in the function, see the following code execution
execution results are as follows:
funcb ok
13 – type が consistent し ま せ ん.
13 – type が consistent し ま せ ん.
main ….
It can be seen that this error can be caught in the Err object inside the function and in the main program that calls it. This indicates that the Err object is global, so it should be understood that the scope of err is valid between an On Error Resume Next statement and an On Error Goto 0. If we add an invalid statement after the funcb call statement, the error MSG box will pop up, indicating that the On Error Resume Next in the function body cannot be applied outside of the function.
These are some of the experiences of using On Error Resume Next. If you understand the above two points, you can better use the error handling functions.
http://blog.csdn.net/zmxj/archive/2009/02/24/3932065.aspx
Reference: http://www.meizi.cn/article.asp?id=4
Read More:
- Unable to find VBScript script engine or error 2738, could not access VBScript runtime
- C ා imitate on error resume next in VB
- On error goto (resume)
- The experience of installing OpenGL in vs2017 under win7 system
- Microsoft VBScript runtime error ‘800a01ad’
- SQLServerException: The server failed to resume the transaction. Desc:ab00000002
- Error 2738. Could not access VBScript run time for custom action.
- Linux learning experience sharing
- Experience of learning VTK
- Adobe Acrobat installation error experience of e1935 0x80070bc9
- Visual studio 2017 experience
- Solve the startup error “something Wen wrong” of NVIDIA geforce experience
- Opne GL es learning experience!
- ArcGIS desktop experience. Similar to: error 000732 output Geodatabase
- Programmers encounter real wonderful interview experience! Did you win? |Programmers have something to say
- Geforce experience appears something went wrong error code 0x0003 error code solution
- Windows batch: File running in the background
- Cause check of unreachable statement exception in Java
- Register global time filter in main.js in Vue
- Solve the error of clearing data in object.assign in Vue