SlideShare a Scribd company logo
Control Flow Functions In VbScript 
Conditional statements allows us to make decisions and to control the flow of execution of a 
script or one of its sections and accordingly repeat actions. 
Usage of VBScript Conditional statements in QTP: 
I) We use conditional statements to insert verification points. 
II) We can user conditional checks for error handling purpose also. 
VBScript mainly provides following 2 types of decision making statements : 
I) If ...Then Statement. 
II) Select Case Statement. 
 Simple If ( Single line without block) statement is Condition is True: 
Dim myDate 
myDate=#10/10/2014# 
if myDate < date then myDate =date+2 ' where current date is 10/13/2014 
msgbox myDate 
'O/P - 10/15/2014 
 Execute block of statements using Simple If 
Dim myDate 
myDate=#10/10/2014# 
if myDate < date then 
myDate =date+2 ' where current date is 10/13/2014 
msgbox myDate 
msgbox "Mindfire solutions" 
End If 
'O/P - 10/15/2014 
Mindfire solutions 
 IF ...Then...Else 
Dim a,b 
a=5 
b=20
If a > b Then 
Msgbox "a is Greater" 
Else 
msgbox "b is Greater" 
End If 
 If...Then...ElseIf..Else Statement 
Dim a 
a = -5 
If a > 0 Then 
Msgbox "a is a POSITIVE Number" 
ElseIf a < 0 Then 
Msgbox "a is a NEGATIVE Number" 
Else 
Msgbox "a is EQUAL than ZERO" 
End If 
 nested if statements 
Dim a 
a = 23 
If a > 0 Then 
Msgbox "The Number is a POSITIVE Number" 
If a = 1 Then 
Msgbox "The Number is Neither Prime NOR Composite" 
Elseif a = 2 Then 
Msgbox "The Number is the Only Even Prime Number" 
Elseif a = 3 Then 
Msgbox "The Number is the Least Odd Prime Number" 
Else 
Msgbox "The Number is NOT 0,1,2 or 3" 
End If 
ElseIf a < 0 Then 
Msgbox "The Number is a NEGATIVE Number" 
Else 
Msgbox "The Number is ZERO" 
End If 
'O/P - The Number is a POSITIVE Number 
The Number is NOT 0,1,2 or 3 
 Select Case statement 
Executes one of several groups of statements, depending on the value of an expression.
Dim num1, num2, operation 
num1=5 
num2=10 
operation= Lcase(InputBox ("Enter an operation")) 
Select Case operation 
Case "add" 
msgbox "res:" &(num1+num2) 
Case "sub" 
msgbox "res:" &(num1-num2) 
Case "div" 
msgbox "res:" &(num2/num1) 
Case Else 
msgbox "res:" &(num1*num2) 
End Select 
Using Control Structures to Make Code Repeat 
For…Next 
The first structure is often referred to as the For…Next loop. The syntax for this structure is 
For counter = start to finish [Step step] 
...code that gets repeated 
Next 
Example: 
' increment loop by 2 
Counter = 1 
Result = 0 
For Counter = 1 to 5 step 2 
Result=Result + Counter 
msgbox Result 
Next
'Example with Exit For 
For Counter=1 to 5 
If Counter=3 Then 
Exit for 
End If 
msgbox Counter 
Next 
Do…Loop 
The first loop structure you can use is the Do While… 
Loop structure. The basic syntax for this structure is 
Do While <Condition> 
….Code with in the loop for repetitive activity 
Loop 
Example: 
Counter = 1 
Do While Counter < 4 
Total =Inputbox("Please enter the total marks in numbers") 
If Total < 30 Then 
MsgBox "Fail" 
ElseIf Total >=30 and Total <=100 then 
Msgbox "Pass" 
Else 
Msgbox "Invalid Marks" 
End If
Counter = Counter + 1 
Loop 
Exit Do While loop: 
i = 0 
Do While i <= 100 
If i > 10 Then 
Exit Do ' Loop Exits if i>10 
End If 
msgbox("The Value of i is : " &i) 
i = i + 2 
Loop 
There is an another piece of DO ..Loop. Below is the syntax: 
Do 
….Code with in the loop for repetitive activity 
Loop Until condition 
Example: 
Counter = 1 
Do 
Total =Inputbox("Please enter the total marks in numbers") 
If Total < 30 Then 
MsgBox "Fail" 
ElseIf Total >=30 and Total <=100 then 
Msgbox "Pass" 
Else 
Msgbox "Invalid Marks" 
End If 
Counter = Counter + 1
Loop until Counter > 4 
Exit Do Until loop: 
i = 0 
Do 
i = i + 2 
If i > 10 Then 
Exit Do ' Loop Exits if i>10 
End If 
msgbox("The Value of i is : " &i) 
Loop Until i > 100 
For Each...Next statement - runs code for each item in a collection or each element of an array 
Example: 
Dim birds(2) 
birds(0)="parrot" 
birds(1)="Crow" 
birds(2)="Sparrow" 
For Each x In birds 
msgbox(x) 
Next 
While...Wend: Executes a series of statements as long as a given condition is True. 
Example: 
Dim Counter 
Counter = 0 ' Initialize variable. 
While Counter < 20 ' Test value of Counter. 
Counter = Counter + 1 ' Increment Counter. 
msgbox Counter 
Wend ' End While loop when Counter > 19.
Conditional statements in vb script

More Related Content

What's hot

C# Loops
C# LoopsC# Loops
C# Loops
Hock Leng PUAH
 
CONDITIONAL STATEMENT IN C LANGUAGE
CONDITIONAL STATEMENT IN C LANGUAGECONDITIONAL STATEMENT IN C LANGUAGE
CONDITIONAL STATEMENT IN C LANGUAGE
Ideal Eyes Business College
 
C if else
C if elseC if else
C if else
Ritwik Das
 
Control structure of c
Control structure of cControl structure of c
Control structure of c
Komal Kotak
 
Conditional Statement in C Language
Conditional Statement in C LanguageConditional Statement in C Language
Conditional Statement in C Language
Shaina Arora
 
Structure in programming in c or c++ or c# or java
Structure in programming  in c or c++ or c# or javaStructure in programming  in c or c++ or c# or java
Structure in programming in c or c++ or c# or java
Samsil Arefin
 
Conditional Loops Python
Conditional Loops PythonConditional Loops Python
Conditional Loops Python
primeteacher32
 
Nesting of if else statement & Else If Ladder
Nesting of if else statement & Else If Ladder Nesting of if else statement & Else If Ladder
Nesting of if else statement & Else If Ladder
Vishvesh Jasani
 
C++ decision making
C++ decision makingC++ decision making
C++ decision making
Zohaib Ahmed
 
C lecture 4 nested loops and jumping statements slideshare
C lecture 4 nested loops and jumping statements slideshareC lecture 4 nested loops and jumping statements slideshare
C lecture 4 nested loops and jumping statements slideshare
Gagan Deep
 
C decision making and looping.
C decision making and looping.C decision making and looping.
C decision making and looping.
Haard Shah
 
Control Statement programming
Control Statement programmingControl Statement programming
Control Statement programming
University of Potsdam
 
Decision statements in c language
Decision statements in c languageDecision statements in c language
Decision statements in c language
tanmaymodi4
 
Control statements anil
Control statements anilControl statements anil
Control statements anil
Anil Dutt
 
Control Structures
Control StructuresControl Structures
Control StructuresGhaffar Khan
 
Control structures ii
Control structures ii Control structures ii
Control structures ii
Ahmad Idrees
 
Program control statements in c#
Program control statements in c#Program control statements in c#
Program control statements in c#
Dr.Neeraj Kumar Pandey
 

What's hot (20)

C# Loops
C# LoopsC# Loops
C# Loops
 
CONDITIONAL STATEMENT IN C LANGUAGE
CONDITIONAL STATEMENT IN C LANGUAGECONDITIONAL STATEMENT IN C LANGUAGE
CONDITIONAL STATEMENT IN C LANGUAGE
 
C if else
C if elseC if else
C if else
 
Control structure of c
Control structure of cControl structure of c
Control structure of c
 
Conditional Statement in C Language
Conditional Statement in C LanguageConditional Statement in C Language
Conditional Statement in C Language
 
Structure in programming in c or c++ or c# or java
Structure in programming  in c or c++ or c# or javaStructure in programming  in c or c++ or c# or java
Structure in programming in c or c++ or c# or java
 
Conditional Loops Python
Conditional Loops PythonConditional Loops Python
Conditional Loops Python
 
Flow of control ppt
Flow of control pptFlow of control ppt
Flow of control ppt
 
Nesting of if else statement & Else If Ladder
Nesting of if else statement & Else If Ladder Nesting of if else statement & Else If Ladder
Nesting of if else statement & Else If Ladder
 
C++ decision making
C++ decision makingC++ decision making
C++ decision making
 
C lecture 4 nested loops and jumping statements slideshare
C lecture 4 nested loops and jumping statements slideshareC lecture 4 nested loops and jumping statements slideshare
C lecture 4 nested loops and jumping statements slideshare
 
C decision making and looping.
C decision making and looping.C decision making and looping.
C decision making and looping.
 
Control structures in C
Control structures in CControl structures in C
Control structures in C
 
Control structure in c
Control structure in cControl structure in c
Control structure in c
 
Control Statement programming
Control Statement programmingControl Statement programming
Control Statement programming
 
Decision statements in c language
Decision statements in c languageDecision statements in c language
Decision statements in c language
 
Control statements anil
Control statements anilControl statements anil
Control statements anil
 
Control Structures
Control StructuresControl Structures
Control Structures
 
Control structures ii
Control structures ii Control structures ii
Control structures ii
 
Program control statements in c#
Program control statements in c#Program control statements in c#
Program control statements in c#
 

Viewers also liked

Vb script
Vb scriptVb script
Vb script
mcatahir947
 
VBscript
VBscriptVBscript
VBscript
vikashraj2090
 
Conditional statements
Conditional statementsConditional statements
Conditional statements
University of Potsdam
 
Intorudction into VBScript
Intorudction into VBScriptIntorudction into VBScript
Intorudction into VBScriptVitaliy Ganzha
 
Audit Imp Q_ Bcom III Year_General & Computers
Audit Imp Q_ Bcom III Year_General & ComputersAudit Imp Q_ Bcom III Year_General & Computers
Audit Imp Q_ Bcom III Year_General & Computers
Palle Chandrika
 
Hand book for 6th semester B.Com Bangalore University
Hand book for 6th semester B.Com Bangalore UniversityHand book for 6th semester B.Com Bangalore University
Hand book for 6th semester B.Com Bangalore University
selfpotent
 
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
 
INTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMINGINTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMING
Abhishek Dwivedi
 

Viewers also liked (8)

Vb script
Vb scriptVb script
Vb script
 
VBscript
VBscriptVBscript
VBscript
 
Conditional statements
Conditional statementsConditional statements
Conditional statements
 
Intorudction into VBScript
Intorudction into VBScriptIntorudction into VBScript
Intorudction into VBScript
 
Audit Imp Q_ Bcom III Year_General & Computers
Audit Imp Q_ Bcom III Year_General & ComputersAudit Imp Q_ Bcom III Year_General & Computers
Audit Imp Q_ Bcom III Year_General & Computers
 
Hand book for 6th semester B.Com Bangalore University
Hand book for 6th semester B.Com Bangalore UniversityHand book for 6th semester B.Com Bangalore University
Hand book for 6th semester B.Com Bangalore University
 
Vb script tutorial for qtp[1]
Vb script tutorial for qtp[1]Vb script tutorial for qtp[1]
Vb script tutorial for qtp[1]
 
INTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMINGINTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMING
 

Similar to Conditional statements in vb script

Chap 4 c++
Chap 4 c++Chap 4 c++
Chap 4 c++
Chap 4 c++Chap 4 c++
ملخص البرمجة المرئية - الوحدة الرابعة
ملخص البرمجة المرئية - الوحدة الرابعةملخص البرمجة المرئية - الوحدة الرابعة
ملخص البرمجة المرئية - الوحدة الرابعة
جامعة القدس المفتوحة
 
4th_Ed_Ch03.pdf
4th_Ed_Ch03.pdf4th_Ed_Ch03.pdf
4th_Ed_Ch03.pdf
ShifatiRabbi
 
C++ and OOPS Crash Course by ACM DBIT | Grejo Joby
C++ and OOPS Crash Course by ACM DBIT | Grejo JobyC++ and OOPS Crash Course by ACM DBIT | Grejo Joby
C++ and OOPS Crash Course by ACM DBIT | Grejo Joby
GrejoJoby1
 
Java căn bản - Chapter6
Java căn bản - Chapter6Java căn bản - Chapter6
Java căn bản - Chapter6Vince Vo
 
Solved Practice Problems For the C++ Exams
Solved Practice Problems For the C++ ExamsSolved Practice Problems For the C++ Exams
Solved Practice Problems For the C++ Exams
MuhammadTalha436
 
Pseudocode By ZAK
Pseudocode By ZAKPseudocode By ZAK
Pseudocode By ZAK
Tabsheer Hasan
 
C101-PracticeProblems.pdf
C101-PracticeProblems.pdfC101-PracticeProblems.pdf
C101-PracticeProblems.pdf
T17Rockstar
 
Practiceproblems(1)
Practiceproblems(1)Practiceproblems(1)
Practiceproblems(1)
Sena Nama
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
Aiman Hud
 
Python for Machine Learning
Python for Machine LearningPython for Machine Learning
Python for Machine Learning
Student
 
CMIS 102 Hands-On Lab Week 4OverviewThis hands-on lab all.docx
CMIS 102 Hands-On Lab Week 4OverviewThis hands-on lab all.docxCMIS 102 Hands-On Lab Week 4OverviewThis hands-on lab all.docx
CMIS 102 Hands-On Lab Week 4OverviewThis hands-on lab all.docx
monicafrancis71118
 
JavaScript 101
JavaScript 101JavaScript 101
JavaScript 101
Mindy McAdams
 
Python programming workshop session 2
Python programming workshop session 2Python programming workshop session 2
Python programming workshop session 2
Abdul Haseeb
 
Miranda NG Project to Get the "Wild Pointers" Award (Part 1)
Miranda NG Project to Get the "Wild Pointers" Award (Part 1) Miranda NG Project to Get the "Wild Pointers" Award (Part 1)
Miranda NG Project to Get the "Wild Pointers" Award (Part 1)
Andrey Karpov
 

Similar to Conditional statements in vb script (20)

Vbscript
VbscriptVbscript
Vbscript
 
Vb script tutorial
Vb script tutorialVb script tutorial
Vb script tutorial
 
Vb script tutorial
Vb script tutorialVb script tutorial
Vb script tutorial
 
Chap 4 c++
Chap 4 c++Chap 4 c++
Chap 4 c++
 
Chap 4 c++
Chap 4 c++Chap 4 c++
Chap 4 c++
 
ملخص البرمجة المرئية - الوحدة الرابعة
ملخص البرمجة المرئية - الوحدة الرابعةملخص البرمجة المرئية - الوحدة الرابعة
ملخص البرمجة المرئية - الوحدة الرابعة
 
4th_Ed_Ch03.pdf
4th_Ed_Ch03.pdf4th_Ed_Ch03.pdf
4th_Ed_Ch03.pdf
 
C++ and OOPS Crash Course by ACM DBIT | Grejo Joby
C++ and OOPS Crash Course by ACM DBIT | Grejo JobyC++ and OOPS Crash Course by ACM DBIT | Grejo Joby
C++ and OOPS Crash Course by ACM DBIT | Grejo Joby
 
Java căn bản - Chapter6
Java căn bản - Chapter6Java căn bản - Chapter6
Java căn bản - Chapter6
 
Solved Practice Problems For the C++ Exams
Solved Practice Problems For the C++ ExamsSolved Practice Problems For the C++ Exams
Solved Practice Problems For the C++ Exams
 
Pseudocode By ZAK
Pseudocode By ZAKPseudocode By ZAK
Pseudocode By ZAK
 
C101-PracticeProblems.pdf
C101-PracticeProblems.pdfC101-PracticeProblems.pdf
C101-PracticeProblems.pdf
 
Practiceproblems(1)
Practiceproblems(1)Practiceproblems(1)
Practiceproblems(1)
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
Python for Machine Learning
Python for Machine LearningPython for Machine Learning
Python for Machine Learning
 
Chap 5 c++
Chap 5 c++Chap 5 c++
Chap 5 c++
 
CMIS 102 Hands-On Lab Week 4OverviewThis hands-on lab all.docx
CMIS 102 Hands-On Lab Week 4OverviewThis hands-on lab all.docxCMIS 102 Hands-On Lab Week 4OverviewThis hands-on lab all.docx
CMIS 102 Hands-On Lab Week 4OverviewThis hands-on lab all.docx
 
JavaScript 101
JavaScript 101JavaScript 101
JavaScript 101
 
Python programming workshop session 2
Python programming workshop session 2Python programming workshop session 2
Python programming workshop session 2
 
Miranda NG Project to Get the "Wild Pointers" Award (Part 1)
Miranda NG Project to Get the "Wild Pointers" Award (Part 1) Miranda NG Project to Get the "Wild Pointers" Award (Part 1)
Miranda NG Project to Get the "Wild Pointers" Award (Part 1)
 

Recently uploaded

The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
AzmatAli747758
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
Nguyen Thanh Tu Collection
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
Celine George
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
Steve Thomason
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
bennyroshan06
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
Fundacja Rozwoju Społeczeństwa Przedsiębiorczego
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 

Recently uploaded (20)

The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 

Conditional statements in vb script

  • 1. Control Flow Functions In VbScript Conditional statements allows us to make decisions and to control the flow of execution of a script or one of its sections and accordingly repeat actions. Usage of VBScript Conditional statements in QTP: I) We use conditional statements to insert verification points. II) We can user conditional checks for error handling purpose also. VBScript mainly provides following 2 types of decision making statements : I) If ...Then Statement. II) Select Case Statement.  Simple If ( Single line without block) statement is Condition is True: Dim myDate myDate=#10/10/2014# if myDate < date then myDate =date+2 ' where current date is 10/13/2014 msgbox myDate 'O/P - 10/15/2014  Execute block of statements using Simple If Dim myDate myDate=#10/10/2014# if myDate < date then myDate =date+2 ' where current date is 10/13/2014 msgbox myDate msgbox "Mindfire solutions" End If 'O/P - 10/15/2014 Mindfire solutions  IF ...Then...Else Dim a,b a=5 b=20
  • 2. If a > b Then Msgbox "a is Greater" Else msgbox "b is Greater" End If  If...Then...ElseIf..Else Statement Dim a a = -5 If a > 0 Then Msgbox "a is a POSITIVE Number" ElseIf a < 0 Then Msgbox "a is a NEGATIVE Number" Else Msgbox "a is EQUAL than ZERO" End If  nested if statements Dim a a = 23 If a > 0 Then Msgbox "The Number is a POSITIVE Number" If a = 1 Then Msgbox "The Number is Neither Prime NOR Composite" Elseif a = 2 Then Msgbox "The Number is the Only Even Prime Number" Elseif a = 3 Then Msgbox "The Number is the Least Odd Prime Number" Else Msgbox "The Number is NOT 0,1,2 or 3" End If ElseIf a < 0 Then Msgbox "The Number is a NEGATIVE Number" Else Msgbox "The Number is ZERO" End If 'O/P - The Number is a POSITIVE Number The Number is NOT 0,1,2 or 3  Select Case statement Executes one of several groups of statements, depending on the value of an expression.
  • 3. Dim num1, num2, operation num1=5 num2=10 operation= Lcase(InputBox ("Enter an operation")) Select Case operation Case "add" msgbox "res:" &(num1+num2) Case "sub" msgbox "res:" &(num1-num2) Case "div" msgbox "res:" &(num2/num1) Case Else msgbox "res:" &(num1*num2) End Select Using Control Structures to Make Code Repeat For…Next The first structure is often referred to as the For…Next loop. The syntax for this structure is For counter = start to finish [Step step] ...code that gets repeated Next Example: ' increment loop by 2 Counter = 1 Result = 0 For Counter = 1 to 5 step 2 Result=Result + Counter msgbox Result Next
  • 4. 'Example with Exit For For Counter=1 to 5 If Counter=3 Then Exit for End If msgbox Counter Next Do…Loop The first loop structure you can use is the Do While… Loop structure. The basic syntax for this structure is Do While <Condition> ….Code with in the loop for repetitive activity Loop Example: Counter = 1 Do While Counter < 4 Total =Inputbox("Please enter the total marks in numbers") If Total < 30 Then MsgBox "Fail" ElseIf Total >=30 and Total <=100 then Msgbox "Pass" Else Msgbox "Invalid Marks" End If
  • 5. Counter = Counter + 1 Loop Exit Do While loop: i = 0 Do While i <= 100 If i > 10 Then Exit Do ' Loop Exits if i>10 End If msgbox("The Value of i is : " &i) i = i + 2 Loop There is an another piece of DO ..Loop. Below is the syntax: Do ….Code with in the loop for repetitive activity Loop Until condition Example: Counter = 1 Do Total =Inputbox("Please enter the total marks in numbers") If Total < 30 Then MsgBox "Fail" ElseIf Total >=30 and Total <=100 then Msgbox "Pass" Else Msgbox "Invalid Marks" End If Counter = Counter + 1
  • 6. Loop until Counter > 4 Exit Do Until loop: i = 0 Do i = i + 2 If i > 10 Then Exit Do ' Loop Exits if i>10 End If msgbox("The Value of i is : " &i) Loop Until i > 100 For Each...Next statement - runs code for each item in a collection or each element of an array Example: Dim birds(2) birds(0)="parrot" birds(1)="Crow" birds(2)="Sparrow" For Each x In birds msgbox(x) Next While...Wend: Executes a series of statements as long as a given condition is True. Example: Dim Counter Counter = 0 ' Initialize variable. While Counter < 20 ' Test value of Counter. Counter = Counter + 1 ' Increment Counter. msgbox Counter Wend ' End While loop when Counter > 19.