SlideShare a Scribd company logo
1 of 3
Download to read offline
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

What's hot

Intorudction into VBScript
Intorudction into VBScriptIntorudction into VBScript
Intorudction into VBScript
Vitaliy Ganzha
 
Vb script tutorial for qtp[1]
Vb script tutorial for qtp[1]Vb script tutorial for qtp[1]
Vb script tutorial for qtp[1]
srikanthbkm
 
Javascript conditional statements 1
Javascript conditional statements 1Javascript conditional statements 1
Javascript conditional statements 1
Jesus Obenita Jr.
 
JavaScript Loop: Optimization of Weak Typing
JavaScript Loop: Optimization of Weak TypingJavaScript Loop: Optimization of Weak Typing
JavaScript Loop: Optimization of Weak Typing
Janlay Wu
 

What's hot (20)

Intorudction into VBScript
Intorudction into VBScriptIntorudction into VBScript
Intorudction into VBScript
 
Vbs
VbsVbs
Vbs
 
Vb script tutorial for qtp[1]
Vb script tutorial for qtp[1]Vb script tutorial for qtp[1]
Vb script tutorial for qtp[1]
 
Vb script
Vb scriptVb script
Vb script
 
Javascript conditional statements
Javascript conditional statementsJavascript conditional statements
Javascript conditional statements
 
Conditional statements in vb script
Conditional statements in vb scriptConditional statements in vb script
Conditional statements in vb script
 
Conditional statements
Conditional statementsConditional statements
Conditional statements
 
Vb script tutorial
Vb script tutorialVb script tutorial
Vb script tutorial
 
Operators used in vb.net
Operators used in vb.netOperators used in vb.net
Operators used in vb.net
 
Vb script tutorial
Vb script tutorialVb script tutorial
Vb script tutorial
 
Looping statements
Looping statementsLooping statements
Looping statements
 
TypeScript, Now.
TypeScript, Now.TypeScript, Now.
TypeScript, Now.
 
Loops in java script
Loops in java scriptLoops in java script
Loops in java script
 
Introduction to TypeScript
Introduction to TypeScriptIntroduction to TypeScript
Introduction to TypeScript
 
Javascript conditional statements 1
Javascript conditional statements 1Javascript conditional statements 1
Javascript conditional statements 1
 
JavaScript Loop: Optimization of Weak Typing
JavaScript Loop: Optimization of Weak TypingJavaScript Loop: Optimization of Weak Typing
JavaScript Loop: Optimization of Weak Typing
 
Switch case and looping jam
Switch case and looping jamSwitch case and looping jam
Switch case and looping jam
 
C# Loops
C# LoopsC# Loops
C# Loops
 
Javascripts hidden treasures BY - https://geekyants.com/
Javascripts hidden treasures            BY  -  https://geekyants.com/Javascripts hidden treasures            BY  -  https://geekyants.com/
Javascripts hidden treasures BY - https://geekyants.com/
 
Program control statements in c#
Program control statements in c#Program control statements in c#
Program control statements in c#
 

Viewers also liked

Журнал "Инфогород". Выпуск 7
Журнал "Инфогород". Выпуск 7Журнал "Инфогород". Выпуск 7
Журнал "Инфогород". Выпуск 7
Moscow IT Department
 
Информационный город 2013: итоги
Информационный город 2013: итогиИнформационный город 2013: итоги
Информационный город 2013: итоги
Moscow IT Department
 
узнай москву презентация
узнай москву презентацияузнай москву презентация
узнай москву презентация
Moscow IT Department
 
Журнал "Инфогород". Выпуск 1
Журнал "Инфогород". Выпуск 1Журнал "Инфогород". Выпуск 1
Журнал "Инфогород". Выпуск 1
Moscow IT Department
 
Журнал "Инфогород". Выпуск 5
Журнал "Инфогород". Выпуск 5Журнал "Инфогород". Выпуск 5
Журнал "Инфогород". Выпуск 5
Moscow IT Department
 

Viewers also liked (20)

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

Similar to Vbscript

Dsp lab _eec-652__vi_sem_18012013
Dsp lab _eec-652__vi_sem_18012013Dsp lab _eec-652__vi_sem_18012013
Dsp lab _eec-652__vi_sem_18012013
Kurmendra Singh
 
C++ control structure
C++ control structureC++ control structure
C++ control structure
bluejayjunior
 

Similar to Vbscript (20)

Vb.net ii
Vb.net iiVb.net ii
Vb.net ii
 
The Ring programming language version 1.5.2 book - Part 175 of 181
The Ring programming language version 1.5.2 book - Part 175 of 181The Ring programming language version 1.5.2 book - Part 175 of 181
The Ring programming language version 1.5.2 book - Part 175 of 181
 
The Ring programming language version 1.4 book - Part 29 of 30
The Ring programming language version 1.4 book - Part 29 of 30The Ring programming language version 1.4 book - Part 29 of 30
The Ring programming language version 1.4 book - Part 29 of 30
 
Javascript
JavascriptJavascript
Javascript
 
Introduction to python programming ( part-2 )
Introduction to python programming ( part-2 )Introduction to python programming ( part-2 )
Introduction to python programming ( part-2 )
 
03 function overloading
03 function overloading03 function overloading
03 function overloading
 
Dsp lab _eec-652__vi_sem_18012013
Dsp lab _eec-652__vi_sem_18012013Dsp lab _eec-652__vi_sem_18012013
Dsp lab _eec-652__vi_sem_18012013
 
Dsp lab _eec-652__vi_sem_18012013
Dsp lab _eec-652__vi_sem_18012013Dsp lab _eec-652__vi_sem_18012013
Dsp lab _eec-652__vi_sem_18012013
 
Ruby Basics
Ruby BasicsRuby Basics
Ruby Basics
 
The Ring programming language version 1.2 book - Part 11 of 84
The Ring programming language version 1.2 book - Part 11 of 84The Ring programming language version 1.2 book - Part 11 of 84
The Ring programming language version 1.2 book - Part 11 of 84
 
The Ring programming language version 1.10 book - Part 101 of 212
The Ring programming language version 1.10 book - Part 101 of 212The Ring programming language version 1.10 book - Part 101 of 212
The Ring programming language version 1.10 book - Part 101 of 212
 
The Ring programming language version 1.5.1 book - Part 19 of 180
The Ring programming language version 1.5.1 book - Part 19 of 180The Ring programming language version 1.5.1 book - Part 19 of 180
The Ring programming language version 1.5.1 book - Part 19 of 180
 
Python programing
Python programingPython programing
Python programing
 
The Ring programming language version 1.3 book - Part 13 of 88
The Ring programming language version 1.3 book - Part 13 of 88The Ring programming language version 1.3 book - Part 13 of 88
The Ring programming language version 1.3 book - Part 13 of 88
 
The Ring programming language version 1.4 book - Part 5 of 30
The Ring programming language version 1.4 book - Part 5 of 30The Ring programming language version 1.4 book - Part 5 of 30
The Ring programming language version 1.4 book - Part 5 of 30
 
ForLoopandUserDefinedFunctions.pptx
ForLoopandUserDefinedFunctions.pptxForLoopandUserDefinedFunctions.pptx
ForLoopandUserDefinedFunctions.pptx
 
C++ control structure
C++ control structureC++ control structure
C++ control structure
 
The Ring programming language version 1.5.4 book - Part 179 of 185
The Ring programming language version 1.5.4 book - Part 179 of 185The Ring programming language version 1.5.4 book - Part 179 of 185
The Ring programming language version 1.5.4 book - Part 179 of 185
 
Error and exception in python
Error and exception in pythonError and exception in python
Error and exception in python
 
Namespaces
NamespacesNamespaces
Namespaces
 

Recently uploaded

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Recently uploaded (20)

ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].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.