Automating Using QTP Day2 Some VbScripting Techniques

What is VBScript ?Scripting Language.
Programming Language Versus Scripting Language..
Scripting - Something you want to do qckly, smply.. Qck development, limited
features,interpreting, interprtr is limited featured tool.

Programming Lanuage  is used for more cmplx featured devlopment.Compiling
My computer is noot work .. Syntax error,Compilation error,keyword is a syntax.
Compiler goes beyond syntax
My computer are not working. Semantic is wrong, checked by Compiler in addition to the Interpreter
Prototype if used is verified by compiler.





VbScripting In Operating Systems :
Large base of windows system administrator fvrom versn 1 to 2.
Batch files being removed by the vbs code lines.

VbScripting  is a litwt scrptng lang wid a fast intrprtr
Windows Scripting host is reqd for scripting engine job for executng the vbs files.
used both sides client as well as servr
Case sensitv lang
any txt editor
Defat lang being asp for server side
98/2000/xp/linux are OS that it supports
General prps scrpting lang
Dtatatype in Vbscript :
Variant.Var
Based on the contxt of usage it recgnizes the usage, such as concat, add in string addition of int context respctvly.
Declaration is a statement used to declare a variable Dim or dimension.
Dim count.
In C lanuage u need to have the datatype explctly mentnd. but herein its all free.
case insenstv
definition is next to declaration is nothing but assigning sm value
Statemt for declaring :
Dim public Private
Function is the storage limitation.
Variable scope an guidelines
Local  and global procedure oriented based.
begn wid alphabet
no keywrd or resrvd wrd.

No .,!,?
Length max 255
unique
Constatnt :
Which does not change.
Scope : ?

Operators :
Arthmetc, cmparsn, concatnmt,logcl.
Arthmtc: Exp,Unary negation, Multipication, division, Integer division, Modulus Arthmtc, Addition, Subbtratcion String concat&
Logical : not,and,or,xor,eqv,imp
Comparison : =,<>,<,>,<=,>=Is

Terminator character is Carrg return.

sopme very basic codes :

Rem Some sample codes
Const v =34
dim a,b,c
'a=8
'b=7
a=Inputbox("Nter Vales ","Value for a" )
b=Inputbox("Nter Vales ","Value for b" )
a=CInt(a)
b=CInt(b)
c=a+b

msgbox(v)
msgbox ("Sum Value : " & c)
msgbox ("Remainder Value : " & a Mod b)
msgbox ("Subtracted Value : " & a - b)
msgbox ("Multiplied Value : " & vbCRlf & a * b)
msgbox ("division Value : " & formatnumber(a / b,2))
msgbox ("Exponentiation Value : " & vbTab & a ^ b)
msgbox ("Not Value : " & NOT b)
msgbox ("Exponentiation Value : " & (a XOR b))
msgbox ("Logical Or Value : " & (a OR b))
msgbox ("Is Greater Value : " & a>b )
msgbox ("Is Less  Value : " & a
msgbox ("Is Value : " & IsNull(a))

e="viplav"
d="anand"
msgbox ("Conactentated Values : " & e+" "+d)
msgbox ("implication : "& (a imp b)) ' value will be -9


'Array Handling in VBSCript

dim arr(2,2)
arr(0,0)=203936
arr(0,1)="Viplav"
arr(1,0)=165451
arr(1,1)="Jan"
arr(2,0)=177826
arr(2,1)="Asw"

dim i
for i=0 to 2
 for j=0 to 1
msgbox (arr(i,j))
 next
next


Binary Operators most of the Arithmetic opertaors, except negation opertaor whihc is a unary opertaor
Precedence :
not and or,xor,eqv,imp

VbCrlf : Carriage return And Line Feed intrinsic constants,
Vbtab  : Tab
vbOK   : 


Conditional Looping :
IF Then Else
Select case
 
These statmnts are used for logical comparison.

WAP to find greatest among three numbers using the If Then Else
WAP to find greatest among four numbers using the If Then Else

For each IF Then there must be one End If to indicate end of the block of IF

WAP to Automate the Calculations for numbers using the Conmditionla Looping Control.


' Select case feature
Select case (i)
case 1:
Msgbox( )
case 2:
Msgbox( )
case else:
Msgbox( )
End select


Loops In Array data Accessing..

For ... Next While .... Wend Do While.... loop For Each... Next

Exit While , Exit For is used to exit the loop

Post a Comment

أحدث أقدم