VBScript Interview Questions and Answers
Q1. What is VBScript?
Ans: Microsoft VBScript (Visual Basic Script) is a wellknown-purpose, light-weight and energetic scripting language developed by Microsoft that is modelled on Visual Basic. Nowadays, VBScript is the number one scripting language for Quick Test Professional (QTP), that is a check automation tool.
Q2. What are the environments supported by means of VBScript language?
Ans: There are three Environments wherein VBScript can run:
IIS (Internet Information Server) – This is Microsoft’s Web Server.
WSH (Windows Script Host) – This is the website hosting environment of the Windows Operating System.
IE (Internet Explorer) – This is the maximum regularly used environment to run scripts and this is the easy website hosting environment.
Q3. How Do I Implement VBScript?
Ans: You use VB Script in exactly the identical way as you would JavaScript. Simply location all code among these tags like so:
<SCRIPT LANGUAGE=”VBScript”>
</SCRIPT>
Q4. What is the extension of the VBScript file?
Ans: VBScript record is stored with an extension of .Vbs.
Q5. What are the benefits of VBScript?
Ans: Following are the blessings of VBScript −
i. VBScript is a lightweight scripting language, which has a lightning rapid interpreter.
Ii. VBScript, for the maximum part, is case insensitive. It has a totally simple syntax, smooth to analyze and to put into effect.
Iii. Unlike C++ or Java, VBScript is an object-based totally scripting language and NOT an Object-Oriented Programming language.
Iv. It makes use of Component Object Model (COM) a good way to get entry to the elements of the surroundings in which it's miles executing.
V. Successful execution of VBScript can manifest best if it's far performed in Host Environment such as Internet Explorer (IE), Internet Information Services (IIS) and Windows Scripting Host (WSH).
Q6. What are the Data Types supported through VBScript?
Ans: VBScript has best one records kind known as a Variant. There are exclusive classes of information that may be contained in a Variant, known as subtypes. These subtypes are:
Empty, Null, Boolean, Byte, Integer, Long Single, Double, Date/Time, Currency , String , Object and Error.
Q7. How are Comments handled inside the VBScript language?
Ans: Any Statement that begins with a single quote (‘) or with the key-word ‘REM’ is dealt with as a Comment.
Q8. What are keywords in the VBScript language?
Ans: There are a few words which work as Reserved Words and that they can not be used as Variables names, Constant names or any other Identifier names are called key phrases. Some of the key phrases within the VBScript language are Not, Nothing, Preserve, Optional, etc.
Q9. What are the variable naming conventions in VBScript?
Ans: Variable is a named reminiscence place used to preserve a fee that can be changed in the course of the script execution. VBScript has only ONE essential facts type, Variant.
Rules for Declaring Variables:-
Variable Name must start with an alphabet.
Variable names can not exceed 255 characters.
Variables Should NOT include a period(.)
Variable Names have to be unique in the declared context.
Q10. What is Dictionary item in VBScript? Explain.
Ans: The Dictionary object shops name / price pairs (referred to as the key and item respectively) in an array.
Write the below code in a notepad and keep it with a .Vbs extension and run it from Command Prompt by simply typing the call of the record.
Dim Beers
Set Beers = CreateObject("Scripting.Dictionary")
Beers.Add "a", "Strauss"
Beers.Add "b", "Kingfisher"
Beers.Add "c", "Budweiser"
Msgbox ("The price corresponding to the important thing 'b' is " & Beers.Item("b"))
The Dictionary object has many residences like Count, Item, CompareMode and so forth and many methods like Exists, Add, and Keys and so on.
Q11. What are the 2 ways wherein a variable may be declared in the VBScript language?
Ans: Two methods to declare a variable are:
Implicit Declaration: When variables are used without delay with out assertion, it is termed as Implicit Declaration. However, it’s no longer an excellent practice because at any factor if the variable name isn't spelled effectively inside the script then it may produce bizarre outcomes even as running and at times, it's going to now not even be smooth to come across this by way of the person.
Explicit Declaration: Declaring the variables before the use of them is referred to as Explicit Declaration of variables.
HubSpot Video
Q12. Which command is used for writing textual content on a page?
Ans: Document.Write (text)
Q13. What's the distinction among VBScript and VB.NET?
Ans: VBScript is script - a textual content-based totally code that receives interpreted by a "host", just like the Windows Script Host or IE. VB.Net is a semi-compiled language for writing java-like software program.
Q14. Why is the use of Exit Do or Exit For statements inside loops discouraged?
Ans: These statements are applicable for unique situations, but they frequently make code much less readable, which makes it difficult for others who study your code to understand what is simply happening. If you make sure the most effective way out of a loop is to not satisfy the loop's circumstance, it's an awful lot easier to comply with your code. Often, breaking out of a loop via pressure with an exit assertion is an indication of a poorly constructed loop with a condition that does not meet your dreams. Take a look at the loop structure and condition again to ensure you're now not leaving something out.
Q15. Compare Java Script and VB Script?
Ans: VB and Java Script are a good deal similar in capability. They each engage with the document item version of the web page. Many browsers fit with Java Script but they may be no longer well suited with VB script as such. For consumer side scripting developers the use of VB Script have to usually ensure of go browser compatibility which is not the case whilst working with VB script.
Q16. What is the scope of a variable declared the use of Dim?
Ans: Variables declared the use of “Dim” key-word at a Procedure stage are to be had only inside the identical process. Variables declared the use of “Dim” Keyword at script stage are available to all of the tactics in the equal script.
Q17. What is the scope of a variable declared the usage of Public?
Ans: Variables declared the usage of “Public” Keyword are to be had to all of the methods across all the associated scripts. When putting forward a variable of kind “public”, Dim key-word is changed by means of “Public”.
Q18. How many varieties of Operators are available within the VBScript language?
Ans: There are 4 sorts of Operators which might be supported by using the VBScript language. They are:
Arithmetic Operators
Comparison Operators
Logical Operators
Concatenation Operators
Q19. How are values assigned to the variables within the VBScript language?
Ans: Values are assigned with the help of Equal (=) Operator. Name of the Variable comes at the left and the fee that is assigned to the Variable is at the Right Hand Side of the ‘=’ Operator.
Q20. What are the differences among Sub Procedures and Function Procedures?
Ans: Differences are as follows:
Sub Procedure in no way takes an enter whilst the Function Procedure may additionally take an enter if required.
Sub Procedure starts offevolved and ends with the usage of Sub and End Sub respectively at the same time as Function Procedure starts offevolved and ends with Function and End Function respectively.
The most essential difference is Sub Procedure by no means returns a value whilst Function Procedure may additionally return a value.
Q21. Explain approximately the capability of VB Script?
Ans: Active X generation can be used to give a good deal greater capability to VB Script. VB offers sub exercises, capabilities, string manipulation, facts/time, mistakes managing, and so on. VB will have more functionality brought to it via operating with languages consisting of ASP.
VBScript is an interpreter language, code written in VBScript is carried out line with the aid of line.
Q22. Explain approximately .Wsf documents?
Ans: .Wsf files are modeled in similar to XML. They can be carried out with the help of Wscript.Exe and it may be executed from the command line additionally. This .Wsf document may have multiple visible primary documents. Reuse capability is present with this extension file.
Q23. How to Assign values to a variable ?
Ans: Simple you have to declare a variable name and assign any value.
For ex. Name=john
Status=False
Age=30
Now all the above variables has been assigned values.This is a easy way to declare and assign related values to a variable.
Q24. List out few date features in VBScript.
Ans: Date(),
Time(),
Now(),
Left(),
Right(),
Mid()
Q25. What are the risks of VBScript?
Ans: Following are the risks of VBScript −
1. VBscript is used most effective by means of IE Browsers. Other browsers along with Chrome, Firefox DONOT Support VBScript. Hence, JavaScript is favored over VBScript.
2. VBScript has a Limited command line aid.
Three. Since there is no development environment to be had with the aid of default, debugging is tough.
Q26. Is VBScript a case-touchy or case-insensitive?
Ans: VBScript is a case-insensitive programming language; i.E. Case is not noted whilst studying VBScript scripts. So myVar, MyVar, MYvar all seek advice from the identical variable.

