VB Script Interview Questions & Answers

  1. Question 1. What Is Vbscript?

    Answer :

    Microsoft VBScript (Visual Basic Script) is a general-purpose, lightweight and active scripting language developed by Microsoft that is modelled on Visual Basic. Nowadays, VBScript is the primary scripting language for Quick Test Professional (QTP), which is a test automation tool.

  2. Question 2. What Are The Advantages Of Vbscript?

    Answer :

    Following are the advantages of VBScript:

    1. VBScript is a lightweight scripting language, which has a lightning fast interpreter.
    2. VBScript, for the most part, is case insensitive. It has a very simple syntax, easy to learn and to implement.
    3. Unlike C++ or Java, VBScript is an object-based scripting language and NOT an Object-Oriented Programming language.
    4. It uses Component Object Model (COM) in order to access the elements of the environment in which it is executing.
    5. Successful execution of VBScript can happen only if it is executed in Host Environment such as Internet Explorer (IE), Internet Information Services (IIS) and Windows Scripting Host (WSH).
  3. VBScript Advanced Interview Questions

  4. Question 3. What Are The Disadvantages Of Vbscript?

    Answer :

    Following are the disadvantages of VBScript:

    1. VBscript is used only by IE Browsers. Other browsers such as Chrome, Firefox DONOT Support VBScript. Hence, JavaScript is preferred over VBScript.
    2. VBScript has a Limited command line support.
    3. Since there is no development environment available by default, debugging is difficult.
  5. Question 4. Is Vbscript Case Sensitive?

    Answer :

    No! VBScript is a case-insensitive language. This means that language keywords, variables, function names and any other identifiers need NOT be typed with a consistent capitalization of letters.

    So identifiers int_counter, INT_Counter and INT_COUNTER have the same meaning within VBScript.

  6. QTP Tutorial

  7. Question 5. What Are The Variable Naming Conventions In Vbscript?

    Answer :

    Variable is a named memory location used to hold a value that can be changed during the script execution. VBScript has only ONE fundamental data type, Variant.

    Rules for Declaring Variables:

    • Variable Name must begin with an alphabet.
    • Variable names cannot exceed 255 characters.
    • Variables Should NOT contain a period(.)
    • Variable Names should be unique in the declared context.
  8. QTP Interview Questions

  9. Question 6. How Do You Declare A Variable In Vbscript?

    Answer :

    Variables are declared using “dim” keyword.

  10. Question 7. Do You Need To Specify The Type Of Variable During Declaration?

    Answer :

    No Since there is only ONE fundamental data type, all the declared variables are variant by default. Hence, a user NEED NOT mention the type of data during declaration.

  11. VB Script Tutorial
    Visual Basics Interview Questions

  12. Question 8. How To Assign A Numeric Value To A Variable?

    Answer :

    The numeric values should be assigned without double quotes.

  13. Question 9. How To Assign A String Value To A Variable?

    Answer :

    The String values should be enclosed within doublequotes(“).

  14. Active Directory Interview Questions

  15. Question 10. How To Assign A Date Value To A Variable?

    Answer :

    Date and Time variables should be enclosed within hash symbol(#).

  16. Software testing Tutorial

  17. Question 11. What Are The Valid Scopes Of A Variable In Vbscript?

    Answer :

    Following are the scopes of variable in VBScript:

    • Dim
    • Public
    • Private
  18. ActiveX Interview Questions

  19. Question 12. What Is The Scope Of A Variable Declared Using Dim?

    Answer :

    Variables declared using “Dim” keyword at a Procedure level are available only within the same procedure. Variables declared using “Dim” Keyword at script level are available to all the procedures within the same script.

  20. VBScript Advanced Interview Questions

  21. Question 13. What Is The Scope Of A Variable Declared Using Public?

    Answer :

    Variables declared using “Public” Keyword are available to all the procedures across all the associated scripts. When declaring a variable of type “public”, Dim keyword is replaced by “Public”.

  22. script.aculo.us Tutorial

  23. Question 14. What Is The Scope Of A Variable Declared Using Private?

    Answer :

    Variables that are declared as “Private” have scope only within that script in which they are declared. When declaring a variable of type “Private”, Dim keyword is replaced by “Private”.

  24. Question 15. How Will You Declare A Constant In Vbscript?

    Answer :

    Constants are declared using “const” keyword.

  25. Software testing Interview Questions

  26. Question 16. What Is The Scope Of A Constant Declared Using Public?

    Answer :

    The Public constants are available for all the scripts and procedures.

  27. Software Development Lifecycle (SDLC) Tutorial

  28. Question 17. What Is The Scopt Of Constant Declared Using Private?

    Answer :

    Private Constants are available within the procedure or Class.

  29. Test Cases Interview Questions

  30. Question 18. How Many Types Of Operators Vbscript Supports?

    Answer :

    VBScript language supports following types of operators:

    1. Arithmetic Operators
    2. Comparison Operators
    3. Logical (or Relational) Operators
    4. Concatenation Operators
  31. QTP Interview Questions

  32. Question 19. Which Opearator Can Be Used To Get The Modulus Of Two Numbers In Vbscript?

    Answer :

    MOD opeator is used to get the modulus of two numbers.

    Example:

    Dim a : a = 5
    Dim b : b = 10
    Dim c
    c = b MOD a
    Document.write (“Modulus Result is ” &c)

  33. Unittest Framework Tutorial

  34. Question 20. Which Opearator Can Be Used To Get The Exponent Of A Number In Vbscript?

    Answer :

    ^ opeator is used to get the exponent of two numbers.

    Example:

    Dim a : a = 5
    Dim b : b = 10
    Dim c
    c = b ^ a
    Document.write (“Exponentiation Result is ” &c)

  35. Software Development Lifecycle (SDLC) Interview Questions

  36. Question 21. Which Opearator Can Be Used To Check If Two Numbers Are Equal Or Not In Vbscript?

    Answer :

    <> operator is used to check if two numbers are equal or not.

    Example:

    Dim a : a = 5
    Dim b : b = 10
    Dim c
    c = b <> a
    Document.write (“Equality Check is ” &c)

  37. Question 22. Which Opearator Can Be Used To Do An Xor Operation In Vbscript?

    Answer :

    XOR Called Logical Exclusion operator. It is used to do an XOR operation.

    Example:

    A. Dim a : a = 5
    Dim b : b = 10
    Dim c
    c = b XOR a
    Document.write (“XOR Check is ” &c)

  38. QUnit Testing Tutorial

  39. Question 23. What Is The Output Of A + B In Vbscript If A = 5 And B = 10?

    Answer :

    + operator adds two Values as Variable Values are Numeric. So A + B will give 15.

  40. Unittest Framework Interview Questions

  41. Question 24. What Is The Output Of A + B In Vbscript If A = “vb” And B = “script”?

    Answer :

    + operator concatenates two Values if values are string. So A + B will give VBScript.

  42. Visual Basics Interview Questions

  43. Question 25. What Is The Output Of A & B In Vbscript If A = 5 And B = 10?

    Answer :

    & operator concatenates two values. So A + B will give 510.

  44. TypeScript Tutorial

  45. Question 26. What Is The Output Of A & B In Vbscript If A = “vb” And B = “script”?

    Answer :

    & operator concatenates two values. So A & B will give VBScript.

  46. QUnit Testing Interview Questions

  47. Question 27. Can You Access Cookie Using Vbscript?

    Answer :

    VBScript can also manipulate cookies using the cookie property of the Document object. JavaScript can read, create, modify, and delete the cookie or cookies that apply to the current web page.

  48. Active Directory Interview Questions

  49. Question 28. How To Create A Cookie Using Vbscript?

    Answer :

    The simplest way to create a cookie is to assign a string value to the document.cookie object, which looks like this:

    Syntax:

    document.cookie = “key1 = value1; key2 = value2; expires = date”;

    Here expires attribute is optional. If you provide this attribute with a valid date or time then cookie will expire at the given date or time and after that cookies’ value will not be accessible.

  50. Question 29. How To Read A Cookie Using Vbscript?

    Answer :

    Reading a cookie is just as simple as writing one, because the value of the document.cookie object is the cookie. So you can use this string whenever you want to access the cookie.

    The document.cookie string will keep a list of name=value pairs separated by semicolons, where name is the name of a cookie and value is its string value.

    You can use strings’ split() function to break the string into key and values.

  51. Microsoft Visual C++ Interview Questions

  52. Question 30. How To Delete A Cookie Using Vbscript?

    Answer :

    Sometimes you will want to delete a cookie so that subsequent attempts to read the cookie return nothing. To do this, you just need to set the expiration date to a time in the past.

  53. Question 31. How Will You Convert A Given Number To Double In Vbscript?

    Answer :

    Using CDbl function, which converts a given number of any variant subtype to double.

    Example:

    x = 123
    y = 123.882
    document.write(“x value after converting to double – ” & CDbl(x) & “
    “)

  54. Question 32. How Will You Convert A Given Number To Integer In Vbscript?

    Answer :

    Using CInt function, which converts a given number of any variant subtype to Integer.

    Example:

    x = 123
    y = 123.882
    document.write(“y value after converting to Int – ” & CInt(y) & “
    “)

  55. TypeScript Interview Questions

  56. Question 33. How Will You Convert A Given Number To Long In Vbscript?

    Answer :

    Using CLng function, which converts a given number of any variant subtype to Long.

    Example:

    x = 123
    y = 123.882
    document.write(“x value after converting to Long -” & CLng(x) & “
    “)

  57. ActiveX Interview Questions

  58. Question 34. How Will You Convert A Given Number To Single In Vbscript?

    Answer :

    Using CSng function, which converts a given number of any variant subtype to Single.

    Example:

    x = 123
    y = 123.882
    document.write(“x value after converting to Single -” & CSng(x) & “
    “)

  59. Question 35. How Will You Convert A Given Number To Hexadecimal In Vbscript?

    Answer :

    Using Hex function, which converts a given number of any variant subtype to Hexadecimal.

    Example:

    x = 123
    y = 123.882
    document.write(“y value after converting to Hex -” & Hex(y) & “
    “)

  60. Question 36. How Will You Format A Number Upto 3 Decimal Places In Vbscript?

    Answer :

    Using FormatNumber function, which would return an expression formatted as a number.

    Example:

    Dim num : num = -645.998651
    document.write(FormatNumber(num, 3))& “
    ”     ‘-645.999

  61. Software testing Interview Questions

  62. Question 37. How Will You Format A Number In Percetage Format In Vbscript?

    Answer :

    Using FormatPercent function, which would return an expression formatted as a percent.

    Example:

    Dim num : num = -645.998651
    document.write(FormatPercent(num, 2))& “
    ”    ‘-64,599.86%

  63. Question 38. How Will You Get The Integer Part Of A Number In Vbscript?

    Answer :

    Using Int function, which returns the integer part of the given number.

    Example:

    Dim num : num = -645.998651
    document.write(“int Result of num is : ” & int(num))& “
    ”  ‘-646

  64. Question 39. How Will You Get The Natural Logarithm Of The Given Number In Vbscript?

    Answer :

    Using Log function, which returns the natural logarithm of the given number.

    Example:

    Dim num : num = 210
    document.write(“Log Result of num2 is : ” & Log(num2))& “
    ” ‘5.34710753071747

  65. Question 40. How Will You Get The Octal Value Of The Given Number In Vbscript?

    Answer :

    Using Oct function, which returns the octal value of the given number.

    Example:

    Dim num : num = -645.998651
    document.write(“Oct Result of num is : ” & Oct(num))& “
    ” ‘37777776572

  66. Test Cases Interview Questions

  67. Question 41. How Will You Get The Hexadecimal Value Of The Given Number In Vbscript?

    Answer :

    Using Hex function, which returns the hexadecimal value of the given number.

    Example:

    Dim num : num = -645.998651
    document.write(“Hex Result of num is : ” & Hex(num))& “
    ” ‘FFFFFD7A

  68. Question 42. How Will You Get A Random Number Between 0 And 1 In Vbscript?

    Answer :

    Using Rnd function,which returns a random number between 0 and 1.

    Example:

    Dim num : num = -645.998651
    document.write(“Rnd Result of num is : ” & Rnd(num))& “
    ” ‘0.5130115

  69. Software Development Lifecycle (SDLC) Interview Questions

  70. Question 43. How Will You Get The Square Root Of The Given Number In Vbscript?

    Answer :

    Using Sqr function, which returns the square root of the given number.

    Example:

    Dim num : num = -210
    document.write(“Sqr Result of num is : ” & Sqr(num))& “
    ” ‘14.4913767461894

  71. Question 44. How Will You Get The Absolute Value Of The Given Number In Vbscript?

    Answer :

    Using Abs function, which returns the absolute value of the given number.

    Example:

    Dim num : num = -645.998651
    document.write(“Abs Result of num is : ” & Abs(num))& “
    ” ‘645.998651

  72. Question 45. How Will You Get The Exponent Of The Given Number In Vbscript?

    Answer :

    Using Exp function, which returns the value of e raised to the specified number.

    Example:

    Dim num : num = -645.998651
    document.write(“Exp Result of num is : ” & Exp(num))& “
    ” ‘2.79479883633128E-281

  73. Question 46. How Will You Get The First Occurrence Of One String Within Another String Using Vbscript?

    Answer :

    Using InStr function, which returns the first occurrence of one string within another string. The search happens from left to right.

  74. Question 47. How Will You Get The Last Occurrence Of One String Within Another String Using Vbscript?

    Answer :

    Using InStrRev function, which returns the first occurrence of one string within another string. The search happens from right to left.

  75. Question 48. How Will You Convert A String To Lower Case String Using Vbscript?

    Answer :

    Using Lcase function, which returns the lower case of the specified string.

  76. Question 49. How Will You Convert A String To Upper Case String Using Vbscript?

    Answer :

    Using Ucase function, which returns the upper case of the specified string.

  77. Question 50. How Will You Trim The Spaces On The Left Of A String Using Vbscript?

    Answer :

    Using Ltrim function, which returns a string after removing the spaces on the left side of the specified string.

  78. Question 51. How Will You Trim The Spaces On The Right Of A String Using Vbscript?

    Answer :

    Using Rtrim function, which returns a string after removing the spaces on the left side of the specified string.

  79. Question 52. How Will You Trim The Leading As Well As Trailing Spaces Of A String Using Vbscript?

    Answer :

    Using Trim function, which returns a string value after removing both leading and trailing blank spaces.

  80. Question 53. How Will You Get Length Of A String Using Vbscript?

    Answer :

    Using Len function, which returns the length of the given string.

  81. Question 54. How Will You Replace A String With Another String Using Vbscript?

    Answer :

    Using Replace function, which returns a string after replacing a string with another string.

  82. Question 55. How Will You Fill The String With The Specified Number Of Spaces Using Vbscript?

    Answer :

    Using Space function, which fills a string with the specified number of spaces.

  83. Question 56. How Will You Compare Two Strings In Vbscript?

    Answer :

    Using StrComp function, which returns an integer value after comparing the two specified strings.

  84. Question 57. How Strcomp Function Works?

    Answer :

    The StrComp Function returns an integer value after comparing the two given strings. It can return any of the three values -1, 0 or 1 based on the input strings to be compared.

    • If String 1 < String 2 then StrComp returns -1
    • If String 1 = String 2 then StrComp returns 0
    • If String 1 > String 2 then StrComp returns 1
  85. Question 58. How Will You Get A String With The Specified Character The Specified Number Of Times In Vbscript?

    Answer :

    Using String function, which returns a String with a specified character the specified number of times.

  86. Question 59. How Will You Reverse A String In Vbscript?

    Answer :

    Using StrReverse function, whihc returns a String after reversing the sequece of the characters of the given string.

  87. Question 60. How To Declare An Array In Vbscript?

    Answer :

    arrays are declared the same way a variable has been declared except that the declaration of an array variable uses parenthesis. In the below example, the size of the array is mentioned in the brackets.

    Example:

    ‘Method 1 : Using Dim
    Dim arr1() ‘Without Size
    ‘Method 2 : Mentioning the Size
    Dim arr2(5)  ‘Declared with size of 5
    ‘Method 3 : using ‘Array’ Parameter
    Dim arr3
    arr3 = Array(“apple”,”Orange”,”Grapes”)

  88. Question 61. How Will You Assign Values To An Array In Vbscript?

    Answer :

    The values are assigned to the array by specifying array index value against each one of the values to be assigned.

    Example:

    Dim arr(5)
    arr(0) = “VBScript”    ‘String
    document.write(“Value stored in Array index 0 : ” & arr(0) & “
    “)

  89. Question 62. How Will You Increase The Size Of An Array In Vbscript?

    Answer :

    Using ReDim statement, we can declare dynamic-array variables and allocate or reallocate storage space.

  90. Question 63. How Will You Get The Smallest Subscript Of An Array In Vbscript?

    Answer :

    Using LBound function, which returns an integer that corresponds to the smallest subscript of the given arrays.

  91. Question 64. How Will You Get The Largest Subscript Of An Array In Vbscript?

    Answer :

    Using UBound function, which returns an integer that corresponds to the largest subscript of the given arrays.

  92. Question 65. How Will You Split A String Into An Array In Vbscript?

    Answer :

    Using Split function, which returns an array that contains a specified number of values. Splitted based on a Delimiter.

  93. Question 66. How Will You Get A Combined String From Array Of String In Vbscript?

    Answer :

    Using Join function, which returns a String that contains a specified number of substrings in an array. This is an exact opposite function of Split Method.

  94. Question 67. How Will You Get A Subset Of A Array In Vbscript?

    Answer :

    Using Filter function, returns a zero based array that contains a subset of a string array based on a specific filter criteria.

  95. Question 68. How Will You Check That A Variable Is An Array In Vbscript?

    Answer :

    Using IsArray function, which returns a boolean value that indicates whether or not the input variable is an array.

  96. Question 69. How Will You Release The Memory Acquired By An Array Variable In Vbscript?

    Answer :

    Using Erase Function, which recovers the allocated memory for the array variables.

  97. Question 70. How To Create A Function In Vbscript?

    Answer :

    The most common way to define a function in VBScript is by using the Function keyword, followed by a unique function name and it may or may not carry a list of parameters and a statement with a End Function keyword, which indicates the end of the function.

  98. Question 71. How To Call A Function In Vbscript?

    Answer :

    To invoke a function somewhere later in the script, you would simple need to write the name of that function with the Call keyword.

  99. Question 72. How To Return A Value From A Function In Vbscript?

    Answer :

    To return a value from a function, simply assign the value to the function name itself.

  100. Question 73. Can In Vbscript, Function Return Multiple Values?

    Answer :

    Yes! A function can return multiple values separated by comma as an array assigned to the function name itself.

  101. Question 74. What Are Subprocedures In Vbscript?

    Answer :

    • Sub Procedures are similar to functions but there are few differences.
    • Sub procedures DONOT Return a value while functions may or may not return a value.
    • Sub procedures Can be called without call keyword.
    • Sub procedures are always enclosed within Sub and End Sub statements.
  102. Question 75. How To Pass Argument By Value To A Function In Vbscript?

    Answer :

    If ByVal is specified, then the arguments are sent as by value when the function or procedure is called.

  103. Question 76. How To Pass Argument By Reference To A Function In Vbscript?

    Answer :

    If ByRef is specified, then the arguments are sent as by reference when the function or procedure is called.

  104. Question 77. How Can You Create An Object In Vbscript?

    Answer :

    we need to declare the object and instantiate it using Set Keyword.

    Example:

    Dim obj  
    Set obj = CreateObject(“Scripting.Dictionary”)

  105. Question 78. How Can You Destroy An Object In Vbscript?

    Answer :

    In order to destroy the objects, we need to use Set Keyword followed by the object name and point it to Nothing.

    Example:

    Dim obj  
    Set obj = CreateObject(“Scripting.Dictionary”)
    Set obj = Nothing

  106. Question 79. What Is A Class In Vbscript?

    Answer :

    Class is a construct that is used to define a unique type. Like Object Oriented Programming, VbScript 5.0 supports the creation of classes and it is very similar to writing COM objects with VB.

    Class is simply the template for an object and we instantiate an object to access the properties and methods of it. Classes can contain variables, properties, methods or events.

  107. Question 80. How To Create A Class In Vbscript?

    Answer :

    VBScript classes are enclosed within Class …. End Class
    ‘Defining the Class
    Class classname    ‘Declare the object name

    End Class
    ‘ Instantiation of the Class
    Set objectname = new classname

  108. Question 81. What Are Class Variables?

    Answer :

    Classes can contain variables, which can be of private or public. Variables within classes should follow VBScript naming conventions. By default, the variables in class are Public. That is why they can be accessed outside the class.

    Example:

    Dim var1 , var2.
    Private var1 , var2.
    Public var1 , var2.

  109. Question 82. What Are Class Properties?

    Answer :

    Class properties, such as Property Let, which handles the process of data validation and assigning the new value to the private variable. Property set, which assigns the new property value to the private object variable.

    Read-only properties have only a Property Get procedure while write-only properties (which are rare) have only a Property Let or a Property Set procedure.

    Example:

    Class Comp
       
       Private modStrType
       Private OS
     
       Public Property Let ComputerType(strType)
          modStrType = strType
       End Property
     
       Public Property Get ComputerType()
          ComputerType = modStrType
       End Property
     
       Public Property Set OperatingSystem(oObj)
          Set OS = oObj
       End Property
     
       Public Property Get OperatingSystem()
          Set OperatingSystem = OS
       End Property
     
    End Class

  110. Question 83. What Are Class Methods?

    Answer :

    Methods allow the class to perform the operation that the developer wants. The Methods are nothing but Functions or Subroutines.

    Example:

    Class Car   
       Private Model
       Private Year 
       Public Start()
          Fuel = 2.45
       Pressure =  4.15
       End Function 
    End Class

  111. Question 84. What Are Class Events?

    Answer :

    There are two events that are automatically associated with every class by default. Class_Initialize and Class_Terminate.

    Class_Initialize is triggered whenever you instantiate an object based on the class. Class_Terminate event is fired when the object goes out of scope or when the object is set to Nothing.

    Example:

    In the below example, we will make you understand how the events work in VBScript.

    ‘Instantation of the Object
    Set objectname = New classname 
       
    Private Sub Class_Initialize(  )
     Initalization code goes here
    End Sub
    ‘When Object is Set to Nothing
    Private Sub Class_Terminate(  )
     Termination code goes here
    End Sub

  112. Question 85. What Is Purpose Of Scripting.filesystemobject Class In Vbscript?

    Answer :

    This class provides file system objects which help the developers to work with drives, folders and files.

    Example:

    Dim oFS, drive
    Set oFS = CreateObject(“Scripting.FileSystemObject”)
    Set drive = oFS.GetDrive(oFS.GetDriveName(“C:”))
    Document.write drive.VolumeName

  113. Question 86. What Is The Purpose Of Drive Object Of Scripting.filesystemobject Class In Vbscript?

    Answer :

    Drive contains methods and properties that allow you to gather information about a drive attached to the system.

  114. Question 87. What Is The Purpose Of File Object Of Scripting.filesystemobject Class In Vbscript?

    Answer :

    File contains methods and properties that allow developers to create, delete or move a file.

  115. Question 88. What Is The Purpose Of Files Object Of Scripting.filesystemobject Class In Vbscript?

    Answer :

    Files provides a list of all files contained within a folder.

  116. Question 89. What Is The Purpose Of Folder Object Of Scripting.filesystemobject Class In Vbscript?

    Answer :

    Folder provides methods and properties that allow developers to create, delete or move folders.

  117. Question 90. What Is The Purpose Of Folders Object Of Scripting.filesystemobject Class In Vbscript?

    Answer :

    Folders provides a list of all the folders within a Folder.

  118. Question 91. What Is The Purpose Of Textstream Object Of Scripting.filesystemobject Class In Vbscript?

    Answer :

    TextStream enables developers to read and write text files.

  119. Question 92. What Is The Purpose Of Regexp Object In Vbscript?

    Answer :

    RegExp object helps the developers to match the pattern of strings and the properties and methods help us to work with Regular Expressions easily.

  120. Question 93. What Are The Properties Of Regexp Object?

    Answer :

    Following are the properties of RegExp object:

    Pattern: The Pattern method represents a string that is used to define the regular expression and it should be set before using the regular expression object.

    IgnoreCase: A Boolean property that represents if the regular expression should be tested against all possible matches in a string if true or false. If not specified explicitly, IgnoreCase value is set to False.

    Global: A Boolean property that represents if the regular expression should be tested against all possible matches in a string. If not specified explicitly, Global value is set to False.

  121. Question 94. How Regexp.test Method Works?

    Answer :

    The Test method takes a string as its argument and returns True if the regular expression can successfully be matched against the string, otherwise False is returned.

  122. Question 95. How Regexp.replace Method Works?

    Answer :

    The Replace method takes 2 parameters. If the search is successful then it replaces that match with the replace-string, and the new string is returned. If there are no matches then the original search-string is returned.

  123. Question 96. How Regexp.execute Method Works?

    Answer :

    The Execute method works like Replace, except that it returns a Matches collection object, containing a Match object for each successful match. It doesn’t modify the original string.

  124. Question 97. How To Capture A Runtime Error In Vbscript?

    Answer :

    If we want to capture the error, then Err Object is used.

  125. Question 98. How To Throw An Error In Vbscript?

    Answer :

    Use Err.Raise to throw an error.

    Example:

    Err.Raise 6   ‘ Raise an overflow error.

  126. Question 99. How To Get The Error Details In Vbscript?

    Answer :

    Err.Number gives the error number and Err.Description gives error description.

    Example:

    Err.Raise 6   ‘ Raise an overflow error.
    MsgBox “Error # ” & CStr(Err.Number) & ” ” & Err.Description

  127. Question 100. How To Clear An Error In Vbscript?

    Answer :

    Err.Clear clear an error.

    Example:

    Err.Raise 6   ‘ Raise an overflow error.
    MsgBox “Error # ” & CStr(Err.Number) & ” ” & Err.Description
    Err.Clear   ‘ Clear the error.