SlideShare a Scribd company logo
VBScript Procedures



In VBScript, there are two types of procedures:

       Sub procedure
       Function procedure



A Sub procedure:

       is a series of statements, enclosed by the Sub and End Sub statements
       does not return a value
       can take arguments
       without arguments, it must include an empty set of parentheses ()

eg.
Sub displayName()
 msgbox("QualityPoint Technologies")
End Sub

or

Sub addvalues(value1,value2)
 msgbox(value1+value2)
End Sub

When calling a Sub procedure you can use the Call statement, like this:

Call MyProc(argument)

Or, you can omit the Call statement, like this:

MyProc argument

A Function procedure:

       is a series of statements, enclosed by the Function and End Function statements
       can return a value
       can take arguments
       without arguments, must include an empty set of parentheses ()
       returns a value by assigning a value to its name
Find below a Sample function.

Function addvalues(value1,value2)
  addvalues=value1+value2
End Function

The above function will take take two arguments and will add those two values and then it will
return the sum value. Note here the sum value is retured by assigning it to the function name.

The above function can be called as below.

msgbox "Sum value is " & addvalues(1,2)

Conditional Statements



In VBScript we have four conditional statements:

if statement - executes a set of code when a condition is true

(e.g) if i=10 then
       msgbox "I am 10"
       End if
if...then...else statement - select one of two sets of lines to execute
(e.g) if i=10 then msgbox "I am 10"
     else msgbox "other than 10"
     end if

  if...then...elseif statement - select one of many sets of lines to execute
     (e.g) if i=10 then msgbox "I am 10"
    elseif i=11 then msgbox "I am 11"
    else msgbox "unknown"
    end if
  select case statement - select one of many sets of lines to execute
  select case value
 case 1
  msgbox "1"
 case 2
  msgbox "2"
 case 3
  msgbox "3"
 case else
  msgbox "other than 1,2 and 3"
end select
Looping Statements

Use the For...Next statement to run a block of code a specified number of times.
e.g
for i = 0 to 5
 msgbox("The number is " & i )
next

If you don't know how many repetitions you want, use a Do...Loop statement.

The Do...Loop statement repeats a block of code while a condition is true, or until a condition
becomes true.

Built-in Functions

VBscript is having many useful built-in functions.
You can refer this page for the complete list
inStr, isNull, LCase, Left, Len, Mid, Now, Replace, Split, UBound, CStr, CreateObject, Date and
DatePart are functions that are most frequently used in QTP script development.

More Related Content

PPT
QTP VB Script Trainings
PPTX
VB Script
PPTX
Basic vbscript for qtp
PPT
VB Script Overview
PPT
Qtp - Introduction to fundamentals of vbscript
DOC
Learn VbScript -String Functions
PPTX
PDF
7400354 vbscript-in-qtp
QTP VB Script Trainings
VB Script
Basic vbscript for qtp
VB Script Overview
Qtp - Introduction to fundamentals of vbscript
Learn VbScript -String Functions
7400354 vbscript-in-qtp

What's hot (20)

PPT
Intorudction into VBScript
PDF
PDF
Vb script tutorial for qtp[1]
PPT
Vb script
PPTX
Javascript conditional statements
DOC
Conditional statements in vb script
PPTX
Conditional statements
DOCX
Vb script tutorial
PPTX
Operators used in vb.net
PDF
Vb script tutorial
PPTX
Looping statements
PPTX
TypeScript, Now.
PPTX
Loops in java script
PPTX
Introduction to TypeScript
PPTX
Javascript conditional statements 1
PPTX
JavaScript Loop: Optimization of Weak Typing
PPTX
Switch case and looping jam
PPTX
C# Loops
PPTX
Javascripts hidden treasures BY - https://geekyants.com/
PPTX
Program control statements in c#
Intorudction into VBScript
Vb script tutorial for qtp[1]
Vb script
Javascript conditional statements
Conditional statements in vb script
Conditional statements
Vb script tutorial
Operators used in vb.net
Vb script tutorial
Looping statements
TypeScript, Now.
Loops in java script
Introduction to TypeScript
Javascript conditional statements 1
JavaScript Loop: Optimization of Weak Typing
Switch case and looping jam
C# Loops
Javascripts hidden treasures BY - https://geekyants.com/
Program control statements in c#
Ad

Viewers also liked (20)

PDF
Vb script
PDF
Vb script reference
PPTX
Coding standards
PDF
VBScript Tutorial
PDF
Журнал "Инфогород". Выпуск 7
PDF
Информационный город 2013: итоги
PDF
узнай москву презентация
PDF
Notice of the 83rd AGM of Poona Club Limited
DOCX
Итоги радиомониторинга качества связи в Москве, июнь 2012 г.
PDF
Журнал "Инфогород". Выпуск 1
PPTX
Открытые данные: от теории к практике
PDF
Инфошкола #1
PPTX
Видеонаблюдение на выборах в Мосгордуму
PDF
Sxsw in tweets 2008
PDF
Бюллетень "Инфошкола". Выпуск 14
PDF
Virtual Worlds in Education Velon 15.03.2011
PDF
Журнал "Инфогород". Выпуск 5
PDF
Активный гражданин. Итоги первой недели
PDF
Agile (mal)Practices Considered Harmful
PDF
Мониторинг покупательской способности москвичей в сфере ИКТ
Vb script
Vb script reference
Coding standards
VBScript Tutorial
Журнал "Инфогород". Выпуск 7
Информационный город 2013: итоги
узнай москву презентация
Notice of the 83rd AGM of Poona Club Limited
Итоги радиомониторинга качества связи в Москве, июнь 2012 г.
Журнал "Инфогород". Выпуск 1
Открытые данные: от теории к практике
Инфошкола #1
Видеонаблюдение на выборах в Мосгордуму
Sxsw in tweets 2008
Бюллетень "Инфошкола". Выпуск 14
Virtual Worlds in Education Velon 15.03.2011
Журнал "Инфогород". Выпуск 5
Активный гражданин. Итоги первой недели
Agile (mal)Practices Considered Harmful
Мониторинг покупательской способности москвичей в сфере ИКТ
Ad

Similar to Vbscript (20)

PPTX
Qtp vb scripting
DOCX
VBScript Functions procedures and arrays.docx
PPT
Qtpvbscripttrainings
DOCX
VBS control structures for if do whilw.docx
PPTX
Vb script final pari
PPT
AVB201.2 Microsoft Access VBA Module 2
PPTX
Array and functions
PPTX
VB Function and procedure
PPSX
VBScript in Software Testing
PDF
procedures and arrays
DOC
Advanced Qtp Book
PPT
Vbscript
PDF
Unit iii vb_study_materials
PPT
30,31,32,33. decision and loop statements in vbscript
PDF
Vba functions
PPTX
Excel VBA.pptx
PPTX
Presentation of computer
PDF
Advanced Qtp Book
PDF
Conditional Statements & Loops
DOC
Advanced+qtp+open+order
Qtp vb scripting
VBScript Functions procedures and arrays.docx
Qtpvbscripttrainings
VBS control structures for if do whilw.docx
Vb script final pari
AVB201.2 Microsoft Access VBA Module 2
Array and functions
VB Function and procedure
VBScript in Software Testing
procedures and arrays
Advanced Qtp Book
Vbscript
Unit iii vb_study_materials
30,31,32,33. decision and loop statements in vbscript
Vba functions
Excel VBA.pptx
Presentation of computer
Advanced Qtp Book
Conditional Statements & Loops
Advanced+qtp+open+order

Recently uploaded (20)

PPTX
A Presentation on Artificial Intelligence
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
Spectroscopy.pptx food analysis technology
PDF
A comparative analysis of optical character recognition models for extracting...
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
sap open course for s4hana steps from ECC to s4
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPT
Teaching material agriculture food technology
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Encapsulation theory and applications.pdf
A Presentation on Artificial Intelligence
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Dropbox Q2 2025 Financial Results & Investor Presentation
Spectroscopy.pptx food analysis technology
A comparative analysis of optical character recognition models for extracting...
Chapter 3 Spatial Domain Image Processing.pdf
Spectral efficient network and resource selection model in 5G networks
sap open course for s4hana steps from ECC to s4
Programs and apps: productivity, graphics, security and other tools
Per capita expenditure prediction using model stacking based on satellite ima...
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
MIND Revenue Release Quarter 2 2025 Press Release
The Rise and Fall of 3GPP – Time for a Sabbatical?
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Review of recent advances in non-invasive hemoglobin estimation
Diabetes mellitus diagnosis method based random forest with bat algorithm
Teaching material agriculture food technology
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Encapsulation theory and applications.pdf

Vbscript

  • 1. VBScript Procedures In VBScript, there are two types of procedures: Sub procedure Function procedure A Sub procedure: is a series of statements, enclosed by the Sub and End Sub statements does not return a value can take arguments without arguments, it must include an empty set of parentheses () eg. Sub displayName() msgbox("QualityPoint Technologies") End Sub or Sub addvalues(value1,value2) msgbox(value1+value2) End Sub When calling a Sub procedure you can use the Call statement, like this: Call MyProc(argument) Or, you can omit the Call statement, like this: MyProc argument A Function procedure: is a series of statements, enclosed by the Function and End Function statements can return a value can take arguments without arguments, must include an empty set of parentheses () returns a value by assigning a value to its name
  • 2. Find below a Sample function. Function addvalues(value1,value2) addvalues=value1+value2 End Function The above function will take take two arguments and will add those two values and then it will return the sum value. Note here the sum value is retured by assigning it to the function name. The above function can be called as below. msgbox "Sum value is " & addvalues(1,2) Conditional Statements In VBScript we have four conditional statements: if statement - executes a set of code when a condition is true (e.g) if i=10 then msgbox "I am 10" End if if...then...else statement - select one of two sets of lines to execute (e.g) if i=10 then msgbox "I am 10" else msgbox "other than 10" end if if...then...elseif statement - select one of many sets of lines to execute (e.g) if i=10 then msgbox "I am 10" elseif i=11 then msgbox "I am 11" else msgbox "unknown" end if select case statement - select one of many sets of lines to execute select case value case 1 msgbox "1" case 2 msgbox "2" case 3 msgbox "3" case else msgbox "other than 1,2 and 3" end select
  • 3. Looping Statements Use the For...Next statement to run a block of code a specified number of times. e.g for i = 0 to 5 msgbox("The number is " & i ) next If you don't know how many repetitions you want, use a Do...Loop statement. The Do...Loop statement repeats a block of code while a condition is true, or until a condition becomes true. Built-in Functions VBscript is having many useful built-in functions. You can refer this page for the complete list inStr, isNull, LCase, Left, Len, Mid, Now, Replace, Split, UBound, CStr, CreateObject, Date and DatePart are functions that are most frequently used in QTP script development.