Top 25 VBScript Interview Questions and Answers (2024)

Here are VBScript interview questions and answers for fresher as well experienced candidates to get their dream job.


VBScript Interview Questions and Answers for Freshers

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,

  • IIS (Internet Information Server) – Microsoft’s web server
  • WSH (Windows Script Host)– The native hosting environment of the Windows OS
  • IE (Internet Explorer)– The simplest hosting environment we can use to run VBS

👉 Free PDF Download: VBScript Interview Questions & Answers

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

VB Script provides Technology as,

  • Subroutines
  • Functions
  • String manipulation
  • Data/time
  • Error Handling, etc.

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

  • Variable name must begin with a letter
  • Variable name cannot exceed 255 characters
  • Variable name should not contain a period (.)

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.

VBScript Interview Questions
VBScript Interview Questions

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.

  • Function procedures start and end with Function and End Function statements
  • A function procedure may or may not take input.
  • Function procedures return a value by assigning the value to its name

9) Mention how you can Call VBScript Functions?

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

  • The mention function name, followed by opening and closing brackets
  • Mention all arguments between the brackets that the function requires

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,

  • Inside Head Section
  • Inside Body Section
  • Inside External File

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?

  • The Option Explicit statement should be there in a script before any other statements. If not then, a nontrappable error occurs
  • In modules where the Option Explicit statement is not declared, any undeclared variables are considered as variants automatically.
  • Where Option Explicit is declared, all variables must be declared using the Dim, Public, Private, or ReDim statements.

VBScript Interview Questions and Answers for Experienced

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?

  • You can use sub procedures if you want to run a series of statement without returning any value.
  • Subprocedures start with “Sub” and end with “End Sub” statements
  • Subprocedures can take arguments but cannot return a value
  • Subprocedures may or may not take input.

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

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.

These interview questions will also help in your viva(orals)