vbscript
vbscript
com
---------------------------------------------------------------------------------------------------------------------------------------------
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.
• Subroutines
• Functions
• String manipulation
• Data/time
• Error Handling, etc.
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 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.
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.
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
To assign a date value to a variable, Date and Time variables should be enclosed within a hash
symbol(#).
The simplest way to create a cookie is to assign a string value to the document.cookie object.
Data in an array can be accessed by referring to the name of the array and the element's index
number.
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?
Page 2|5
https://www.guru99.com
---------------------------------------------------------------------------------------------------------------------------------------------
If you do not specify anything when you call a procedure, then the argument/arguments are
passed by reference by default.
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.
• 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 are 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.
VBA VBScript
• In VBA, you can explicitly define the lower • In VBScript, this is not
bound of an array in the subscripts permitted; the lower
argument. bound of all arrays is
always 0.
• You can use sub procedures if you want to run a series of statement without returning any
value.
• Sub procedures start with "Sub" and ends with "End Sub" statements
Page 3|5
https://www.guru99.com
---------------------------------------------------------------------------------------------------------------------------------------------
• Sub procedures can take arguments but cannot return a value
• Sub procedures may or may not take an input.
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 on 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.
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 where
as 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.
Scrrun.dll is used very much in programming VB. 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.
Page 4|5
https://www.guru99.com
---------------------------------------------------------------------------------------------------------------------------------------------
Guru99 Provides FREE ONLINE TUTORIAL on Various courses like
Page 5|5