Home > Error Checking > Error Checking Vbscript

Error Checking Vbscript

Contents

Never assume .NET Framework is installed. Use descriptive names for variables, functions and subroutines You are (almost) completely free to use any name for a variable, subroutine or function. Scripting: eternally fascinating, eternally new. How This Book Should Be Used How This Book Is Structured Conventions in This Book How To Contact Us I. his comment is here

Is this possible? Is compares an object reference with another object reference or a keyword that can refer to an object to see if they are the same. It then checks the return code of the method with a Select Case decision-making structure. If a "self-contained" subroutine or function has been debugged, it will save debugging time when you reuse it in another script.

Error Checking Javascript

For example, the following line causes a syntax error because it is missing a closing parenthesis: Runtime errors Runtime errors, If subroutines or (user defined) functions are used, log each call to these subroutines, it will help you follow the program flow. The easiest way to do this is to generate the error using the Err.Raise method and providing the error code to the ErrorNumber parameter, then sit back and note how your

VBScript error-handling requires two elements that work together. strError = VbCrLf & strMessage & VbCrLf & _ "Number (dec) : " & Err.Number & VbCrLf & _ "Number (hex) : &H" & Hex(Err.Number) & VbCrLf & _ "Description : You can not catch those errors, because it depends on your business requirement what type of logic you want to put in your program. Vbscript Error Codes As you may have noticed, I use the prefix my for parameter names in my own scripts.

So don't touch that dial: stay tuned for Part 2 of "To Err Is VBScript." Top of page Resources Windows 2000 Scripting Guide - VBScript Overview – Error Handing - VBScript Error Checking Visual Basic Use Err or Err.Number and Err.Description to detect and log and maybe even correct errors. Split it up in several lines, each without nested functions, and use variables to contain the intermediate results: strFullPath = "C:\Documents and Settings\Me\Application Data" intLastSlash = InStrRev( strFullPath, "\" ) strParentName Depending on the speed of the network and the machines involved, this may take a few seconds or more per machine.

Example In the below example, Err.Number gives the error number and Err.Description gives error description.