SlideShare a Scribd company logo
VB Script By: Ali Imran Khan [email_address]
VBScript is a scripting language  Scripting language is a lightweight programming language  VBScript is a light version of Microsoft's programming language Visual Basic VBScript can be used for both client-side and server-side programming.
VBScript Variables A variable is a "container" for information you want to store.  Naming Rules : Must begin with an alphabetic character Cannot contain a period Cannot exceed 255 characters Must be unique within its scope
Lifetime OF Variables Local Variables: When you declare a variable within a procedure, the variable can only be accessed within that procedure. When the procedure exits, the variable is destroyed. You can have local variables with the same name in different procedures, because each is recognized only by the procedure in which it is declared. Global Variables: If you declare a variable outside a procedure, all the procedures on your page can access it. The lifetime of these variables starts when they are declared, and ends when the script is closed.
Variable (Cont) Declaration: Dim  Keyword is used to Declare a variable You can Assign a Value to variable directly (without declaring a variable). But not a good practice. Option Explicit  Keyword is used to restrict variables to be declared before their usage. Example: Option explicit Dim var_ x var_x=1
Constants Const  keyword is used to declare constants. It is necessary to initialize the Constant during its declaration. You cannot change the value of constants  in later script. Syntax: const x=1
Practical Work !
Arrays An array is a set of variables conveniently packages for easy handling   Sometimes you want to assign more than one value to a single variable. Then you can create a variable that can contain a series of values. This is called an array variable
Arrays (cont.) The declaration of an array variable uses parentheses  ( ) following the variable name. Example: dim names(2) names(0)=“Ali“ names(1)=“Imran“ names(2)=“Khan"
Arrays (cont.) An array can be multi dimensional. There can be 60 (maximum) dimensions in an array.  Multiple dimensions are declared by separating the numbers in the parentheses with commas.
Practical Work !
Procedures A Sub procedure: is a series of statements, enclosed by the Sub and End Sub statements  can perform actions, but  does not return  a value  can take arguments that are passed to it by a calling procedure  without arguments, must include an empty set of parentheses ()
Procedures (Cont) Sub  Keyword is Used  to declare a procedure. End Sub  Keyword is Used  to defining the ending boundary of a procedure. Call  Keyword is Used in order to invoke a procedure. Syntax: Sub mysub()  some statements  End Sub Call mysub()
Procedures (Cont) Procedure can take arguments that are passed to it by  calling that procedure . Syntax: Sub procedure name(arg1,arg2)  some statements  End Sub Call mysub(value1,value2)
Practical Work !
Functions A Function procedure: is a series of statements, enclosed by the Function and End Function statements  can perform actions and  can return  a value  can take arguments that are passed to it by a calling procedure  without arguments, must include an empty set of parentheses ()  returns a value by assigning a value to its name
Functions (Cont) Function  Keyword is Used  to declare a Function. End Function  Keyword is Used  to defining the ending boundary of a Function. <Function Name>  is Used in order to invoke a Function. Syntax: Function myfunc()  some statements  End Function myfunc
Practical Work !
If Condition If   keyword is used for executing a set of code when certain condition is true. Endif   keyword is used to end the if condition code block. Syntax: If  <condition> then  Some statements End if
If-Else Condition if...then...else  - use this keyword if you want to select one of two sets of lines to execute  if...then...elseif  - use this keyword if you want to select one of many sets of lines to execute
If-Else Condition (cont.) Syntax : if <condition> then  Some statements Else Some statements end If
If-Elseif Condition (cont.) Syntax : if <condition> then  Some statements Elseif <condition> then Some statements Else Some statements end If
Practical Work !
Select Case Condition Select   case   keyword is used to execute one of many blocks of code. Syntax select case <variable> case <first expected value> Some statements case <second expected value> Some statements ……… ……… case Else  Some Statements end select
Practical Work !
For Loop For loop is used to execute set of statements , pre defined number of iterations. For … Next  keywords are used to implement the For Loop. Syntax: For <Loop initialization state> to <ending condition> Some Statements Next
For Loop (cont.) Step   keyword is used to increase or decrease the counter variable by the specified value.  Syntax For <Loop initialization state> To <ending condition> Step <Increment/Decrement value> some statements Next
For Loop (cont.) You can use for loop in order to repeat a block of code for each item in a collection, or for each element of an array. Syntax: For Each  <variable name >  in  <array Variable Name> <Some Statements> Next
Practical Work !
Do-while loop Do-while   keywords are used to execute specified code for a set of times (until a condition remains true or a condition becomes false). Syntax Do While <Condition for loop> Some  Statements Loop
Do-while loop (cont.) Do-While   can also used in following syntax: Do  some Statements  Loop While i>10
Do-Until Loop  Do – Until  keyword is used for repeating some set of statements until a certain condition is true. Syntax: Do Until <Condition> some statmemts Loop
Do-Until Loop (cont.) Do-Until   can also used in following syntax: Do  some statements Loop Until <Condition>
Practical Work !
Built in Functions VB Script provides several built in functions that can be used just by calling them. Few Examples: Date Time Int
Practical Work !
Thank You !

More Related Content

PPTX
Introduction to System verilog
PDF
System Verilog Functional Coverage
PDF
Session 8 assertion_based_verification_and_interfaces
PDF
How to create SystemVerilog verification environment?
PPTX
COMPILER DESIGN
PPTX
SOC Verification using SystemVerilog
PPTX
PPT
system verilog
Introduction to System verilog
System Verilog Functional Coverage
Session 8 assertion_based_verification_and_interfaces
How to create SystemVerilog verification environment?
COMPILER DESIGN
SOC Verification using SystemVerilog
system verilog

What's hot (20)

PPTX
Method Overloading in Java
ODP
White box ppt
PPTX
Type checking in compiler design
PDF
Session 7 code_functional_coverage
PDF
Ral by pushpa
PPTX
Event Handling in java
PPTX
System verilog coverage
PPTX
Java awt (abstract window toolkit)
PPTX
White Box Testing
PPT
PPTX
Symbol Table
PPTX
Java exception handling
PPTX
Syntax Analysis in Compiler Design
PDF
Python exception handling
PPTX
Bruteforce algorithm
PPTX
Advanced Python : Decorators
PDF
Generics
PPT
Coupling and cohesion
PDF
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
PPTX
Time advance mehcanism
Method Overloading in Java
White box ppt
Type checking in compiler design
Session 7 code_functional_coverage
Ral by pushpa
Event Handling in java
System verilog coverage
Java awt (abstract window toolkit)
White Box Testing
Symbol Table
Java exception handling
Syntax Analysis in Compiler Design
Python exception handling
Bruteforce algorithm
Advanced Python : Decorators
Generics
Coupling and cohesion
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
Time advance mehcanism
Ad

Viewers also liked (9)

PPTX
Basic vbscript for qtp
DOCX
Fundamentos de la mecatrónica por francisco esaul servin cosgaya
PPT
vb script
PDF
VBScript Tutorial
PDF
Ingenieria de control w bolton
PDF
Todo lo que se debe saber para la selección de bombas y diseños de sistemas h...
PDF
Vb script hx-c-wd
PDF
Instrumentacion industrial creus 8th
Basic vbscript for qtp
Fundamentos de la mecatrónica por francisco esaul servin cosgaya
vb script
VBScript Tutorial
Ingenieria de control w bolton
Todo lo que se debe saber para la selección de bombas y diseños de sistemas h...
Vb script hx-c-wd
Instrumentacion industrial creus 8th
Ad

Similar to QTP VB Script Trainings (20)

PPTX
PPTX
VB Script
DOCX
Vb script tutorial
PDF
Vb script tutorial
PPTX
Qtp vb scripting
DOCX
VBS control structures for if do whilw.docx
DOCX
VBScript Functions procedures and arrays.docx
DOC
Conditional statements in vb script
PDF
Vba functions
PDF
Vbscript
PPSX
VBScript in Software Testing
PPTX
Vba Class Level 1
PPTX
Array and functions
PPT
AVB201.2 Microsoft Access VBA Module 2
PPT
VB Script Overview
PPT
QTP Presentation2
PPT
Vbscript
PPT
Qtpvbscripttrainings
PPT
Ms vb
DOC
Excel Vba Basic Tutorial 1
VB Script
Vb script tutorial
Vb script tutorial
Qtp vb scripting
VBS control structures for if do whilw.docx
VBScript Functions procedures and arrays.docx
Conditional statements in vb script
Vba functions
Vbscript
VBScript in Software Testing
Vba Class Level 1
Array and functions
AVB201.2 Microsoft Access VBA Module 2
VB Script Overview
QTP Presentation2
Vbscript
Qtpvbscripttrainings
Ms vb
Excel Vba Basic Tutorial 1

Recently uploaded (20)

PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
PPTX
Spectroscopy.pptx food analysis technology
PPT
Teaching material agriculture food technology
PDF
Machine learning based COVID-19 study performance prediction
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Empathic Computing: Creating Shared Understanding
PDF
A comparative analysis of optical character recognition models for extracting...
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
1. Introduction to Computer Programming.pptx
PPTX
SOPHOS-XG Firewall Administrator PPT.pptx
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Electronic commerce courselecture one. Pdf
PDF
cuic standard and advanced reporting.pdf
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
Accuracy of neural networks in brain wave diagnosis of schizophrenia
Spectroscopy.pptx food analysis technology
Teaching material agriculture food technology
Machine learning based COVID-19 study performance prediction
20250228 LYD VKU AI Blended-Learning.pptx
“AI and Expert System Decision Support & Business Intelligence Systems”
Empathic Computing: Creating Shared Understanding
A comparative analysis of optical character recognition models for extracting...
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Digital-Transformation-Roadmap-for-Companies.pptx
Diabetes mellitus diagnosis method based random forest with bat algorithm
Agricultural_Statistics_at_a_Glance_2022_0.pdf
1. Introduction to Computer Programming.pptx
SOPHOS-XG Firewall Administrator PPT.pptx
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Dropbox Q2 2025 Financial Results & Investor Presentation
Electronic commerce courselecture one. Pdf
cuic standard and advanced reporting.pdf
Building Integrated photovoltaic BIPV_UPV.pdf

QTP VB Script Trainings

  • 1. VB Script By: Ali Imran Khan [email_address]
  • 2. VBScript is a scripting language Scripting language is a lightweight programming language VBScript is a light version of Microsoft's programming language Visual Basic VBScript can be used for both client-side and server-side programming.
  • 3. VBScript Variables A variable is a &quot;container&quot; for information you want to store. Naming Rules : Must begin with an alphabetic character Cannot contain a period Cannot exceed 255 characters Must be unique within its scope
  • 4. Lifetime OF Variables Local Variables: When you declare a variable within a procedure, the variable can only be accessed within that procedure. When the procedure exits, the variable is destroyed. You can have local variables with the same name in different procedures, because each is recognized only by the procedure in which it is declared. Global Variables: If you declare a variable outside a procedure, all the procedures on your page can access it. The lifetime of these variables starts when they are declared, and ends when the script is closed.
  • 5. Variable (Cont) Declaration: Dim Keyword is used to Declare a variable You can Assign a Value to variable directly (without declaring a variable). But not a good practice. Option Explicit Keyword is used to restrict variables to be declared before their usage. Example: Option explicit Dim var_ x var_x=1
  • 6. Constants Const keyword is used to declare constants. It is necessary to initialize the Constant during its declaration. You cannot change the value of constants in later script. Syntax: const x=1
  • 8. Arrays An array is a set of variables conveniently packages for easy handling Sometimes you want to assign more than one value to a single variable. Then you can create a variable that can contain a series of values. This is called an array variable
  • 9. Arrays (cont.) The declaration of an array variable uses parentheses ( ) following the variable name. Example: dim names(2) names(0)=“Ali“ names(1)=“Imran“ names(2)=“Khan&quot;
  • 10. Arrays (cont.) An array can be multi dimensional. There can be 60 (maximum) dimensions in an array. Multiple dimensions are declared by separating the numbers in the parentheses with commas.
  • 12. Procedures A Sub procedure: is a series of statements, enclosed by the Sub and End Sub statements can perform actions, but does not return a value can take arguments that are passed to it by a calling procedure without arguments, must include an empty set of parentheses ()
  • 13. Procedures (Cont) Sub Keyword is Used to declare a procedure. End Sub Keyword is Used to defining the ending boundary of a procedure. Call Keyword is Used in order to invoke a procedure. Syntax: Sub mysub() some statements End Sub Call mysub()
  • 14. Procedures (Cont) Procedure can take arguments that are passed to it by calling that procedure . Syntax: Sub procedure name(arg1,arg2) some statements End Sub Call mysub(value1,value2)
  • 16. Functions A Function procedure: is a series of statements, enclosed by the Function and End Function statements can perform actions and can return a value can take arguments that are passed to it by a calling procedure without arguments, must include an empty set of parentheses () returns a value by assigning a value to its name
  • 17. Functions (Cont) Function Keyword is Used to declare a Function. End Function Keyword is Used to defining the ending boundary of a Function. <Function Name> is Used in order to invoke a Function. Syntax: Function myfunc() some statements End Function myfunc
  • 19. If Condition If keyword is used for executing a set of code when certain condition is true. Endif keyword is used to end the if condition code block. Syntax: If <condition> then Some statements End if
  • 20. If-Else Condition if...then...else - use this keyword if you want to select one of two sets of lines to execute if...then...elseif - use this keyword if you want to select one of many sets of lines to execute
  • 21. If-Else Condition (cont.) Syntax : if <condition> then Some statements Else Some statements end If
  • 22. If-Elseif Condition (cont.) Syntax : if <condition> then Some statements Elseif <condition> then Some statements Else Some statements end If
  • 24. Select Case Condition Select case keyword is used to execute one of many blocks of code. Syntax select case <variable> case <first expected value> Some statements case <second expected value> Some statements ……… ……… case Else Some Statements end select
  • 26. For Loop For loop is used to execute set of statements , pre defined number of iterations. For … Next keywords are used to implement the For Loop. Syntax: For <Loop initialization state> to <ending condition> Some Statements Next
  • 27. For Loop (cont.) Step keyword is used to increase or decrease the counter variable by the specified value. Syntax For <Loop initialization state> To <ending condition> Step <Increment/Decrement value> some statements Next
  • 28. For Loop (cont.) You can use for loop in order to repeat a block of code for each item in a collection, or for each element of an array. Syntax: For Each <variable name > in <array Variable Name> <Some Statements> Next
  • 30. Do-while loop Do-while keywords are used to execute specified code for a set of times (until a condition remains true or a condition becomes false). Syntax Do While <Condition for loop> Some Statements Loop
  • 31. Do-while loop (cont.) Do-While can also used in following syntax: Do some Statements Loop While i>10
  • 32. Do-Until Loop Do – Until keyword is used for repeating some set of statements until a certain condition is true. Syntax: Do Until <Condition> some statmemts Loop
  • 33. Do-Until Loop (cont.) Do-Until can also used in following syntax: Do some statements Loop Until <Condition>
  • 35. Built in Functions VB Script provides several built in functions that can be used just by calling them. Few Examples: Date Time Int