VB Script, What is VB Script, VB Script
and QTP
What is VBScript?
VBScript is the sub language of Visual
Basic 4.0 programming language. It is called scripting language. It
is developed because Microsoft gives us more powerful processing
power on client server for web pages. Actually VBScript language can
be used to code on both sides server and client side scripting. Even
if you don't aware about the VB Script even then if is easy to learn
and use to work with QTP
First we will discuss about Data
types in VB Script -:
Only one type of data types is
supported by the VB Script which is called 'Variant'. This is special
type of data type which can contains different types of information.
It's also the default data type and returned by all the function
available in VBScript. Actually variant is like a numerical data type
but when it used f numeric or string then it returned in same
context. So its also possible in VB Script to make numbers behaves as
same as string by enclosing them with in the quote.
Variables in VBScript :-
Variables like a place holder that
contains the memory locatioin that store the programs information
that can change dynamically at run time. Variable is just refereed by
its name for accessing the value saved or to edited its value.
Variables Declaration :-
There are three ways to declare the
variables in VB Script -
- Dim Statement
- Public Statement
- Private Statement
For Example -:
Dim No_Passengers
You also declare multiple variables by
following ways:
Dim Left, Right, Top, Bottom
one more thing variable also can be
declare by implicitly by simply using its name in available script.
That will not be a good practice because there are possibilities of
mistakes of misspelling of variables.
There fore Option Explicit statement is
available to required explicit declaration for all the variables.
Note:
Variable declare with Dim at the level
of script is available to all the procedures with in the scripts. So
at procedure level, variable is available only with in the
procedures.
Public statement is default used
for all the procedures in all the scripts.
Private statement variable is
used to only for any specific script and after this it can not be
used in another script.
Naming Convention:
There are some standard rules for
naming in VBScript which are provided below:
- Variable starts with the an alphabetic character.
- Embedded period can not be contain
- Variable name must not exceed more than 255 character
- Variables Must be unique and the scope in which it declared.
Value assignment to Variables :-
Two ways of assigning the values to
variables are:
Scalar Variables :- Dim Top
Top = 200
Array Variables like – Dim
Top(11)
Constants:
Constants in VBScript |
No comments:
Post a Comment