excelnsa.blogg.se

Vb6 try catch
Vb6 try catch













vb6 try catch vb6 try catch

If the error was fatal to the script, you could replace the second Err.clear with WScript.Quit(Err.Number).Īlso note the On Error Goto 0 which turns off resuming execution at the next statement when an error occurs. WScript.Echo "This text will always print."Ībove, we're just printing out the error if it occurred. WScript.Echo "Description: " & Err.Description WScript.Echo "Error (Hex): " & Hex(Err.Number) Set myObj = CreateObject("SomeKindOfClassThatDoesNotExist") ' Other Code Here (that may have raised an Error)Įrr.Clear ' Clear any possible Error that previous code raised First we enable that (often at the top of a file but you may use it in place of the first Err.Clear below for their combined effect), then before running our possibly-error-generating code, clear any errors that have already occurred, run the possibly-error-generating code, and then explicitly check for errors: On Error Resume Next A sort of an "older style" of error handling is available to us in VBScript, that does make use of On Error Resume Next.















Vb6 try catch