Top 25 VBScript Interview Questions & Answers
Posted by Superadmin on April 09 2019 12:55:41

Following are frequently asked questions in interviews for freshers as well experienced VBScript developer.

1) Mention what is VBScript?

VB Script stands for Visual Basic Script, and it is a light version of Microsoft Visual Basic. It is a client-side scripting language like JavaScript. VBScript is very similar to that of Visual Basic.

2) Mention the environments where VBScript could be run?

VBScript could be run into 3 environments,

3) Mention what is the technology used by VB Script?

VB Script provides Technology as,

4) Mention what are the rules to name variable in VBScript?

To name variable in VBScript there are certain rules, you need to use the keyword 'Dim'. For example, Dim salary. Also, you need to remember the following things

5) Explain what is loose binding? Why is it not a good practice to use it?

VBScript allows you to use variables without declaring it known as 'loose binding.' It is not an ideal practice to use it. Because if you misspell the same variable when you use it again then VBScript will not show you of the error.

6) Mention what is variant in VBScript?

A variant in VBScript is a data type. A Variant can contain either string or numeric information. A Variant behaves like a string when you use it in a string context and as a number when you use it in a number context.

7) Mention what is VBScript Procedures?

VBScript procedures are primarily used for code organization and reuse. There are mainly two types of VBScript procedures: Sub procedures and Function procedures.

8) Mention when to use Function procedures and what are its characteristics?

You use Function procedures when you want to execute a series of statements and return a value.

9) Mention how you can Call VBScript Functions?

To call VBScript Functions, you have to follow below rules.

10) Mention how to assign a date value to a variable?

To assign a date value to a variable, Date and Time variables should be enclosed within a hash symbol(#).

11) Mention how to create a Cookie using VBScript?

The simplest way to create a cookie is to assign a string value to the document.cookie object.

12) Mention how to access Array Data?

Data in an array can be accessed by referring to the name of the array and the element's index number.

13) In HTML file what is an ideal position to include VBScript?

An ideal position to include VBScript in HTML is,

14) Mention what is ByRef and ByVal Parameters in VBScript?

ByRef and ByVal Parameters in VBScript is used to pass VBScript argument to the procedures by reference or by value

15) Mention what if you do not specify anything when you call a procedure?

If you do not specify anything when you call a procedure, then the argument/arguments are passed by reference by default.

16) Mention what is the use of Option Explicit in VBScript?

The use of Option Explicit statement in VBScript is to initialize all the variable before using them. It helps to avoid typing error in the code.

17) Mention the rules for using Option Explicit statement?

18) Mention what is the difference between VBScript and VBA?

Difference between VBScript and VBA is that,

VBA

VBScript

  • In VBA, you can explicitly define the lower bound of an array in the subscripts argument.
  • In VBScript, this is not permitted; the lower bound of all arrays is always 0.
  • VBA supports the WithEvents keyword to allow an object reference to receiving notification of the events fired by its corresponding object.
  • VBScript, however, does not support the WithEvents keyword.
  • VBA supports the New keyword to create early-bound objects.
  • A new keyword is not supported in a variable declaration statement

19) Mention characteristics of Sub procedures?

20) Mention what is Select Case statement?

Select Case statement is similar to If Then Else but it makes the code more readable.

It works on a single expression and evaluated at the beginning of the Select Case statement.

21) Mention if QTP generates VBScript code as we record actions, can't it possible to directly write using VBScript code when QTP does the same thing too?

No. it is not possible. QTP is the engine that runs through it. The VBScript relies on the QTP UI to perform the actions, such as clicking on a link on a web page.

22) Write a code to print numbers from 5 to 0?

For i=5 To 0 step -1
WScript.Echo i
Next

23) Mention what is the main difference between function and sub-procedure?

The main difference between function and sub-procedure is that function returns a value whereas a Sub-procedure does not.

24) In what way program "hello world" you can write in VBScript?

In VBScript, you can write hello world in two ways, the program will display a message box with text hello world.

  1. MsgBox "Hello World"
  2. Echo "Hello World"

25) Explain about scrrun.dll in VBScript?

Scrrun.dll is used very much in programming VB. The scripting Runtime library is very important for the functioning of the Visual basic script. It provides much more functionality such as text operations, file management, and file modification features.