Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

1.

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.

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.

2.

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

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

3.

How To Throw An Error In Vbscript?

Answer»

Use Err.RAISE to THROW an ERROR.

Example:

Err.Raise 6 ' Raise an OVERFLOW error.

Use Err.Raise to throw an error.

Example:

Err.Raise 6 ' Raise an overflow error.

4.

How To Capture A Runtime Error In Vbscript?

Answer»

If we WANT to capture the ERROR, then Err Object is used.

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

5.

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.

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.

6.

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.

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.

7.

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.

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.

8.

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.

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.

9.

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.

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

10.

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

Answer»

TextStream enables DEVELOPERS to READ and WRITE text FILES.

TextStream enables developers to read and write text files.

11.

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.

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

12.

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.

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

13.

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.

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

14.

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.

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

15.

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.

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

16.

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

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

17.

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

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

18.

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

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

19.

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

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

20.

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

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

21.

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.

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.

22.

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

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

23.

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")

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

Example:

Dim obj
Set obj = CreateObject("Scripting.Dictionary")

24.

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.

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

25.

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.

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

26.

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.

27.

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.

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

28.

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.

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

29.

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.

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

30.

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.

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.

31.

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.

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

32.

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.

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

33.

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.

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

34.

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.

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.

35.

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.

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

36.

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.

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

37.

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.

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

38.

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.

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

39.

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) & "<br /&GT;")

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) & "<br />")

40.

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")

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")

41.

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.

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

42.

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.

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

43.

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

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.

44.

How Will You Compare Two Strings In Vbscript?

Answer»

Using StrComp function, which RETURNS an integer VALUE after COMPARING the TWO specified strings.

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

45.

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.

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

46.

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.

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

47.

How Will You Get Length Of A String Using Vbscript?

Answer»

Using LEN function, which returns the LENGTH of the given STRING.

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

48.

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.

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

49.

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.

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

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.

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