Friday, March 2, 2012

VB Script | Interview Questions of VBScript | VBScriptDipak



VB Script | Interview Questions of VBScript | VBScriptDipak




1. Which command is used for writing text on a page?
Document.Write (text)

2. What is VBScript?
VBScript stands for Visual Basic Scripting Edition. It is an Active Scripting language, which is developed by Microsoft.
VBScript has been installed by default in every desktop release of Microsoft Windows.
VBScript language is a lightweight programming language, the newest member of the Visual Basic family of
programming languages, brings active scripting to a wide variety of
environments, including Web client scripting in Microsoft IE version 3.0 and Web server scripting in Microsoft Internet
Information Server version 3.0.

3. What is the difference between function and procedure in vb script?

Functions must be set equal to a return value while a procedure does not.

4. Declare a class in VBScript?
Class, refers to any object that you create using the Class ... End Class statement.
Class User
' declare private class variable
Private m_userName
' declare the property
Public Property Get UserName
UserName = m_userName
End Property
Public Property Let UserName (strUserName)
m_userName = strUserName
End Property
' declare and define the method
Sub DisplayUserName
Response.Write UserName
End Sub
End Class

Dim obj
Set obj = New User
' set the UserName property
obj.UserName = "Deepak Madheshiya"
' call the DisplayUserName method
' to print the user name
obj.DisplayUserName

5. VBScript is a case-sensitive programming language or not?
VBScript is not case-sensitive programming language.

6. How many ways you to create an Array in VBScript?
1st way:
Dim myArray(3)
myArray(0) = "Apple"
myArray(1) = "Banana"
myArray(2) = "Cat"
myArray(3) = "Dog"

2nd Way:
myArray = Array(5,10,15,20)

7. What is Dictionary object?
The Dictionary object are those objects who stores name and value in pairs in an array. Value pairs means key and item
Write the below code in a notepad and save it with .vbs extension and run it from
Command Prompt.
Dim wine
Set wine = CreateObject("Scripting.Dictionary")
Beers.Add "a", "Strauss"
Beers.Add "b", "Kingfisher"
Beers.Add "c", "Budweiser"
Msgbox ("The value corresponding to the key 'b' is " & wine.Item("b"))
Dictionary object properties:Count, Item, CompareMode etc.
Dictionary object methods:Exists, Add,Keys etc.

8. What is the difference between dictionary and an array object?
Dictionary object can not be multidimensionalArray object can be multidimensional
Dictionary has extra methods like add, checkNot in Array object
When you delete any specific item from dictionary, all the subsequent items automatically
shift up.
Not in Array

9. What is "On Error Resume Next" statement in VBScript?
When an error occurs, by using this statement, the line of code containing the error
is simply skipped over and the program continues.

10. Which object provide information single runtime error in a VBScript?
Err Object

11. What is difference between VBScript and VBA?
Visual Basic is a standalone tool for creating separate
software components such as executable programs, COM
components and ActiveX? Controls. It is useful when
building a specialised solution from scratch.
VBA offers the same powerful tools as Visual Basic in the context of
an existing application and is the best option for
customising software that already meets most needs.
VBScript is a lightweight version of the Visual Basic
language designed specifically for use on web pages. While
VBScript can sometimes be used for simple automation, VBA
is the premier technology designed specifically for
application automation.
VBScript doesn't have a debugger like Visual BasicVisual Basic and Visual Basic for Applications, in which the developer can
define the data type
12. What are the Data Types in VBScript?
VBScript has only one Variant datatype. There are different categories
of Variant datatype:
String, Integer, Null, Boolean, Empty, Byte, Long Single, Double, Date/Time, Currency, Object and Error.

13. Which function allows you to instantiate an object in VBScript?

CreateObject function


No comments:

Post a Comment