To avoid application may get system failure or Crash, we can use the Error Handling in VB Script
-> On Error Resume Next (if we want bypass the error, we can use this statement)
-> On Error goto 0 (Deactivate On error Resume Next)
-> Error objects (Err) has
-> Description Property (while running we get error description. err.Description())
-> HelpContext Property
-> Helpfile Property (When error occurred we go for help file content using this property)
-> Number Property ( Its throw error number)
-> Source Property (from where this error occurred)
Methods are
-> Clear Method ( Its automatiocally invoked while end of function)
-> Raise Metod (used for user defined method)
Programming Script
------------------
1)
On Error Resume Next
Dim a,b
a=12
b 9
msgbox a+b
o/p 12
The above script we have Error (b 9), but "on Error Resume next" bypass the error and move to next statement.
2)
On Error Resume Next
Dim a,b
a=12
b 9
msgbox a+b
on Error goto 0
b 9
o/p 12 and show error too
The above script deactivate the "on error resume next" uding "on error goto 0" statement.
3)
On Error Resume Next
Dim a,b
a=12
b 9
msgbox a+b
msgbox "Error Source = " &err.source
msgbox "Error Description =" &err.Description
msgbox "Error Number = " &err.Number
msgbox "" &err.Clear
o/p
12
Error Source = Microsoft VBscript Runtime error
Error Description = Wrong number of arguments or invalid property assignment
Error Number = 450
No comments:
Post a Comment