VBScript Interview Questions and Answers

30+ TOP VBScript Questions and Answers

VBScript Interview Questions
VBScript Interview Questions

1. What are the different types of operators and their order of precedence?
Order of evaluation of operators is, first arithmetic operators are evaluated, and comparison operators are evaluated next and at the last logical operators are evaluated at the last. In arithmetic operators negation, Exponentiation, multiplication and division, integer division, modulus arithmetic, addition and subtraction and string concatenation are provided.

2. Explain about operator precedence in VB Script?
In operator precedence expressions are evaluated and resolved in a predetermined order. The order of evaluation can be modulated if you use parenthesis. Expressions present in parenthesis are evaluated first.

3. Explain about Tristate constants in VBScript?
Tristate constants can be used with functions which allow formatting of numbers. These constants can be used with VB Script without defining them. It can be used anywhere in the code to reflect and represent the values.

4. Explain about constants in VBScript?
There are many useful constants present in Visual basic script which you can use in your code. They ease your work load by remembering value and implementing in the code. Maintenance is easy with VB Script because it can easily change the feature of constants.

5. Explain about filter expression?
Filter expression returns an array based on a specific filter search condition and it returns a zero based array. Arguments included in the filter array are Input strings, value, include and compare. If there is no match for the value it returns an empty string.

6. Explain about the Asc function?
According to the first letter in a string it returns the ANSI code relevant to that first letter. If string is not present then a runtime error occurs. Asc function returns the first byte used. It is used only with elements containing byte data in a string.

7. Explain about arrays in VB Script?
Arrays in VB Script should be assigned within the variant separated by a comma. If arguments are not specified then the string is regarded as empty. After specifying the elements in an array an index number should be used indicating the desired element.

8. Explain about ADODB.Stream class?
ADODB.Stream class can be used as string builder. VBScript string concatenation can be very costly because of frequent memory allocation features. Binary file and memory I/O operation is provided by ADODB.Stream class. This is widely used to convert bytes into string, etc.

9. Explain about scrrun.dll?
Scripting Runtime library is very important for the functioning of Visual basic script because it gives much more functionality such as File management, text operations and file modification features. Scrrun.dll is used very much in programming VB.

10. Explain about the functionality of VBScript?
Active X technology can be used to give much more functionality to VB Script. VB provides sub routines, functions, string manipulation, data/time, error handling, etc. VB can have more functionality added to it by working with languages such as ASP.

11. Explain about the support of ASP for VB Script functionality?
Visual Basic should rely on ASP for sever side processing. Asp.dll is used to make VB Script run on ASP engine and it invokes vbscript.dll. VB Script should be embedded within <% and %> context switches. ASP can provide varied functionality to VB Script.

12. Compare JavaScript and VBScript?
VB and JavaScript are much similar in functionality. They both interact with the document object model of the page. Many browsers have compatibility with Java Script but they are not compatible with VB script as such. For client side scripting developers using VB Script should always make sure of cross browser compatibility which is not the case when working with VBScript.

13. Explain some uses of VB Script?
If functionality aspect is considered VB Script acts similar to Java Script but it is compatible only on internet explorer. They interact with Document object model. Visual basic script can also be used for server side processing with ASP.

14. Explain about the extension .hta?
.hta extension is used whenever you want to include a VB script in HTML. Here HTML acts as an interface and VB Script as the programming language. .hta extension files do run in the safe and trusted zone of Internet explorer. Although they run in the trusted zone querying is restricted as it has to pass the guidelines of internet explorer.

15. Explain about .wsf files?
.wsf files are modeled in similar to XML. They can be executed with the help of Wscript.exe and it can be done from the command line also. This .wsf file can have multiple visual basic files. Reuse functionality is present with this extension file.

16. What is event handling in VBScript?
The actions that are performed by clicking, pressing keys, moving mouse, dragging and dropping etc are called as events. Event handling is the way to capture these events and perform the actions accordingly.

17. Explain few date functions in VBScript.

18. What are string functions in VBScript?
Asc() – Returns ANSI Character Code
Chr() – Returns Character from ANSI Code
InStr() – Find a string within another
InStrRev() – Find a string within another (Reverse)
LCase() – Convert a string to lowercase
Left() – Crops a string from left
Len() – Determine the length of a string
LTrim() – Remove leading spaces from a string
Mid() – Crops a string
Replace() – Replace a substring within a string
Right() – Crops a string from right
RTrim() – Remove trailing spaces from a string
Space() – Creates a string with the specified number of spaces
StrComp() – Compare two strings
String() – Creates a repeated character string
StrReverse() – Reverse the characters of a string
Trim() – Remove both leading and trailing spaces from a string
UCase() – Convert a string to uppercase

19. Explain VBScript in detail.
This is a scripting language developed by Microsoft and is based loosely on Visual Basic. Its functionality in a web environment is defendant upon either an ASP engine or the Windows Scripting Host, and must be used on a Windows hosting platform.

20. Give examples where VB script can directly run on users system with Windows as OS?
A simple example detailing the running of VB Script is by utilizing Windows Script host environment. Visual basic is a stand alone application which has a .vbs as extension. Input can be provided through graphical user interface and output can be obtained by Wscript.exe from dialog and input boxes. From command line it can be invoked by Cscript.exe.

21. Explain about VB Script?
VB script is a Microsoft programming language and it resembles a lower version of the VB. It is an Active Scripting language. This scripting language is included in windows operating system by default. With the use of msscript.ocx you can install VB Script.

22. If we take 2 strings as “Good” and “Bad” then what will ‘+’ and ‘&’ operators return?

‘&’ and ‘+’ both works as a Concatenation Operator in case of the String values. Hence these both will return the same result as GoodBad.

23. Which Operator can be used to change the value of the operand or change the state of the condition?

‘NOT’ Operator which is used as a logical operator can be used to change the value of the operand or change the state of the condition i.e. if the condition is True then this will change it to False and vice versa.

24. Out of the different type of Operators, which are evaluated first and last in the VBScript language?

‘Arithmetic’ Operators are evaluated first and ‘Logical’ Operators are evaluated at last in the VBScript language.

25. Which conditional statement is the most convenient one to use in the case of multiple conditions in the VBScript language?

‘Select Case’ is the most convenient one to use in case of multiple conditions in the VBScript language as in case of Select Statement, you can directly move to the exact case without wasting time to go into each condition one by one.

26. What are the different types of loops available in the VBScript language?

The loops which are available in the VBScript language are broadly categorized into 3 types and they are – For Loops, Do Loops and While Loops.

27. Which loop is used in case of arrays in the VBScript language?

For Each loop is used in case of Arrays. This is an extension of For Loop only. When you want to repeat the code for each index value of an array then you can use ‘For Each Loop’.

28. What is the difference between For loop and While loop?

This is a very important Interview Question which is been asked many times.

For loop is used when we exactly know the number of times loop (i.e. for i = start to end) has to be executed unlike in case of while loop.

In ‘for loop’ in the VBScript, the counter is incremented automatically if not mention step keyword by 1 when loops go to next keyword whereas in ‘while loop’, the counter condition has to be mentioned explicitly inside the brackets.

29. What is the difference between Do Until loop and Do While loop?

Do While loop first checks the condition and if it is true only after that the statements are executed and in case of Do Until, the loop will be executed until the condition becomes false.

30. How many types of Procedures are available in the VBScript language?

There are 2 types of Procedures in the VBScript language – Sub Procedures and Function Procedures.

Sub is a type of procedure which includes a set of statements inside the block of the code and after execution, it does not return any value.

The Function is a type of procedure which includes a set of statements inside the block of the code and after execution may return value also. This can take input if required, depending on the situations.

Frequently Asked VBScript Interview Questions