SlideShare a Scribd company logo
VISUAL BASIC
Decision Making Statements

                             By Pragya Ratan Sagar
1




Introduction
All comparison operators produce true or false results. In other
words, the comparison is either true or the comparison is false. The
mathematical operators produce numeric values, whereas the
comparison operators produce only true or false values. The rest of
the program can use the true or false comparison operator result to
make decisions. Comparison operators are operators that compare
data values against each other and produce true or false results.
2




Decision Making Statements
Decision Making Statements are of Two types:

 The IF Statement
If performs one of two possible code actions, depending on the
result of the comparison.

 Select Case statement
Select case mainly used for multiple conditional statements or
If we have a lot of conditional statements then we use Select
Case Statement
3




The ‘IF’ Statement
Perhaps the most important statement in a program is the If
statement and then its statements. In other words, If uses
comparison operator results to test data. If might execute one or
more lines of subsequent code, depending on the result of a
comparison.

 In Visual Basic we use three types of ‘IF’ statements:
         1.   Simple IF
         2.   IF Else
         3.   Nested IF
4

Syntax of ‘IF’ statement in
visual basic
 Simple ‘IF’ :
  Simple IF used only for one condition.
  Syntax :
           If logical_expression Then
                 One or more Visual Basic statements
           End If (block close)
  Example :
           Dim x As Integer
           Dim y As Integer
           x=3
           y=4
           If x > y Then
                MsgBox ("a is greater then b")
           Else
                MsgBox ("b is greater then a")
           End If
5


 IF Else :
Whereas If executes code based on the condition's true condition, the
Else statement executes code based on the condition's false condition
  Syntax :
          If logical_expression Then
               One or more Visual Basic statements
          Else
               One or more Visual Basic statements
          End If
Example :
          If (num > 0) Then
               Print “Number is Positive“
          Else
               Print “Number is negative"
          End If
 Nested IF :                                                 6
    Nested if used when we have more then one conditions to
    compare.
  Syntax :
           If logical_expression Then
               One or more Visual Basic statements
           Else If logical_epression Then
               One or more Visual Basic statements
           Else
               One or more Visual Basic statements
           End If
Example :
           If temp < 0 Then
               Print “Too Cold”
           Else IF temp > 100 Then
               Print “Too Hot”
           Else
               Print “Temperature OK”
           End If
7




Select Case statement
If we have a lot of conditional statements, using If..Then..Else could
be very messy. For multiple conditional statements, it is better to
use Select Case or Select Case allows multiway branching through
the code.
8


Syntax for ‘Select Case’
statement in visual basic
 Select Case :
  Syntax :
        Select Case expression ‘expression maybe string or numeric
           Case value1
              Block of one or more VB statements
           Case value2
              Block of one or more VB Statements
           Case value3
              Block of one or more VB statements
           Case value4
              .
              .
              .
           Case Else
              Block of one or more VB Statements
        End Select
9


Example :
      Select Case M
          Case 4,5 ‘months a and 5
             Print “Spring”
          Case 6,7 ‘months 6 and 7
             Print ‘Summer”
          Case 8 To 10 ‘months 8,9 and 10
             Print “Autumn”
          Case 1 To 3,11,12 ‘months 1,2,3,11,12
             Print “Winter”
          Case Else ‘not in range 1 To 12
             Print M “is not recognised as a months”
      End Case
VISUAL BASIC
Decision Making Statements
             By
      Pragya Ratan Sagar

More Related Content

What's hot

C# lecture 2: Literals , Variables and Data Types in C#
C# lecture 2: Literals , Variables and Data Types in C#C# lecture 2: Literals , Variables and Data Types in C#
C# lecture 2: Literals , Variables and Data Types in C#
Dr.Neeraj Kumar Pandey
 
Control structures in java
Control structures in javaControl structures in java
Control structures in java
VINOTH R
 
Java Exception handling
Java Exception handlingJava Exception handling
Java Exception handling
kamal kotecha
 
Introduction to visual basic programming
Introduction to visual basic programmingIntroduction to visual basic programming
Introduction to visual basic programmingRoger Argarin
 
Control Structures in Visual Basic
Control Structures in  Visual BasicControl Structures in  Visual Basic
Control Structures in Visual BasicTushar Jain
 
python conditional statement.pptx
python conditional statement.pptxpython conditional statement.pptx
python conditional statement.pptx
Dolchandra
 
Object Oriented Programming
Object Oriented ProgrammingObject Oriented Programming
Object Oriented Programming
Iqra khalil
 
Java database connectivity with MySql
Java database connectivity with MySqlJava database connectivity with MySql
Java database connectivity with MySql
Dhyey Dattani
 
Arrays in Java
Arrays in JavaArrays in Java
Arrays in Java
Naz Abdalla
 
Conditional and control statement
Conditional and control statementConditional and control statement
Conditional and control statement
narmadhakin
 
Object Oriented Programming Concepts
Object Oriented Programming ConceptsObject Oriented Programming Concepts
Object Oriented Programming Conceptsthinkphp
 
Introduction to java beans
Introduction to java beansIntroduction to java beans
Introduction to java beans
Hitesh Parmar
 
C# Framework class library
C# Framework class libraryC# Framework class library
C# Framework class library
Prem Kumar Badri
 
Java program structure
Java program structureJava program structure
Java program structure
shalinikarunakaran1
 
Looping statement in vb.net
Looping statement in vb.netLooping statement in vb.net
Looping statement in vb.netilakkiya
 
Statements and Conditions in PHP
Statements and Conditions in PHPStatements and Conditions in PHP
Statements and Conditions in PHP
Maruf Abdullah (Rion)
 
Object Oriented Programming Using C++
Object Oriented Programming Using C++Object Oriented Programming Using C++
Object Oriented Programming Using C++
Muhammad Waqas
 
Visual programming lecture
Visual programming lecture Visual programming lecture
Visual programming lecture
AqsaHayat3
 
Web controls
Web controlsWeb controls
Web controls
Sarthak Varshney
 

What's hot (20)

C# lecture 2: Literals , Variables and Data Types in C#
C# lecture 2: Literals , Variables and Data Types in C#C# lecture 2: Literals , Variables and Data Types in C#
C# lecture 2: Literals , Variables and Data Types in C#
 
Control structures in java
Control structures in javaControl structures in java
Control structures in java
 
Java Exception handling
Java Exception handlingJava Exception handling
Java Exception handling
 
Introduction to visual basic programming
Introduction to visual basic programmingIntroduction to visual basic programming
Introduction to visual basic programming
 
Control Structures in Visual Basic
Control Structures in  Visual BasicControl Structures in  Visual Basic
Control Structures in Visual Basic
 
python conditional statement.pptx
python conditional statement.pptxpython conditional statement.pptx
python conditional statement.pptx
 
Object Oriented Programming
Object Oriented ProgrammingObject Oriented Programming
Object Oriented Programming
 
Java database connectivity with MySql
Java database connectivity with MySqlJava database connectivity with MySql
Java database connectivity with MySql
 
Arrays in Java
Arrays in JavaArrays in Java
Arrays in Java
 
Conditional and control statement
Conditional and control statementConditional and control statement
Conditional and control statement
 
Java packages
Java packagesJava packages
Java packages
 
Object Oriented Programming Concepts
Object Oriented Programming ConceptsObject Oriented Programming Concepts
Object Oriented Programming Concepts
 
Introduction to java beans
Introduction to java beansIntroduction to java beans
Introduction to java beans
 
C# Framework class library
C# Framework class libraryC# Framework class library
C# Framework class library
 
Java program structure
Java program structureJava program structure
Java program structure
 
Looping statement in vb.net
Looping statement in vb.netLooping statement in vb.net
Looping statement in vb.net
 
Statements and Conditions in PHP
Statements and Conditions in PHPStatements and Conditions in PHP
Statements and Conditions in PHP
 
Object Oriented Programming Using C++
Object Oriented Programming Using C++Object Oriented Programming Using C++
Object Oriented Programming Using C++
 
Visual programming lecture
Visual programming lecture Visual programming lecture
Visual programming lecture
 
Web controls
Web controlsWeb controls
Web controls
 

Similar to Vb decision making statements

Decision statements
Decision statementsDecision statements
Decision statements
Jaya Kumari
 
Decision structures chpt_5
Decision structures chpt_5Decision structures chpt_5
Decision structures chpt_5cmontanez
 
Working with comparison operators
Working with comparison operatorsWorking with comparison operators
Working with comparison operatorsSara Corpuz
 
If and select statement
If and select statementIf and select statement
If and select statement
Rahul Sharma
 
W4-DecisionMaking.pdf. python document. CS
W4-DecisionMaking.pdf. python document. CSW4-DecisionMaking.pdf. python document. CS
W4-DecisionMaking.pdf. python document. CS
MalikaKhan21
 
Cso gaddis java_chapter3
Cso gaddis java_chapter3Cso gaddis java_chapter3
Cso gaddis java_chapter3mlrbrown
 
10-Lec - Nested IF Statement.pptx
10-Lec - Nested IF Statement.pptx10-Lec - Nested IF Statement.pptx
10-Lec - Nested IF Statement.pptx
AqeelAbbas94
 
Decision Structures
Decision StructuresDecision Structures
Decision Structures
primeteacher32
 
1.4 conditions and loops
1.4   conditions and loops1.4   conditions and loops
1.4 conditions and loopsallenbailey
 
Decision making and branching
Decision making and branchingDecision making and branching
Decision making and branching
Hossain Md Shakhawat
 
Python decision making
Python   decision makingPython   decision making
Python decision making
Learnbay Datascience
 
Advanced VB: Review of the basics
Advanced VB: Review of the basicsAdvanced VB: Review of the basics
Advanced VB: Review of the basicsrobertbenard
 
Advanced VB: Review of the basics
Advanced VB: Review of the basicsAdvanced VB: Review of the basics
Advanced VB: Review of the basicsrobertbenard
 
Javascript conditional statements
Javascript conditional statementsJavascript conditional statements
Javascript conditional statements
nobel mujuji
 
Variable, constant, operators and control statement
Variable, constant, operators and control statementVariable, constant, operators and control statement
Variable, constant, operators and control statementEyelean xilef
 
Variable, constant, operators and control statement
Variable, constant, operators and control statementVariable, constant, operators and control statement
Variable, constant, operators and control statementEyelean xilef
 

Similar to Vb decision making statements (20)

Decision statements
Decision statementsDecision statements
Decision statements
 
Decision structures chpt_5
Decision structures chpt_5Decision structures chpt_5
Decision structures chpt_5
 
Decisions
DecisionsDecisions
Decisions
 
Decisions
DecisionsDecisions
Decisions
 
Working with comparison operators
Working with comparison operatorsWorking with comparison operators
Working with comparison operators
 
Decisions
DecisionsDecisions
Decisions
 
If and select statement
If and select statementIf and select statement
If and select statement
 
W4-DecisionMaking.pdf. python document. CS
W4-DecisionMaking.pdf. python document. CSW4-DecisionMaking.pdf. python document. CS
W4-DecisionMaking.pdf. python document. CS
 
Cso gaddis java_chapter3
Cso gaddis java_chapter3Cso gaddis java_chapter3
Cso gaddis java_chapter3
 
10-Lec - Nested IF Statement.pptx
10-Lec - Nested IF Statement.pptx10-Lec - Nested IF Statement.pptx
10-Lec - Nested IF Statement.pptx
 
Decision Structures
Decision StructuresDecision Structures
Decision Structures
 
Programming note C#
Programming note C#Programming note C#
Programming note C#
 
1.4 conditions and loops
1.4   conditions and loops1.4   conditions and loops
1.4 conditions and loops
 
Decision making and branching
Decision making and branchingDecision making and branching
Decision making and branching
 
Python decision making
Python   decision makingPython   decision making
Python decision making
 
Advanced VB: Review of the basics
Advanced VB: Review of the basicsAdvanced VB: Review of the basics
Advanced VB: Review of the basics
 
Advanced VB: Review of the basics
Advanced VB: Review of the basicsAdvanced VB: Review of the basics
Advanced VB: Review of the basics
 
Javascript conditional statements
Javascript conditional statementsJavascript conditional statements
Javascript conditional statements
 
Variable, constant, operators and control statement
Variable, constant, operators and control statementVariable, constant, operators and control statement
Variable, constant, operators and control statement
 
Variable, constant, operators and control statement
Variable, constant, operators and control statementVariable, constant, operators and control statement
Variable, constant, operators and control statement
 

Recently uploaded

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
 
Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
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
 
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
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
PedroFerreira53928
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
EduSkills OECD
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
Col Mukteshwar Prasad
 
Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)
rosedainty
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
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
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 
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
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 

Recently uploaded (20)

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
 
Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
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
 
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
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
 
Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
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
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
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
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 

Vb decision making statements

  • 1. VISUAL BASIC Decision Making Statements By Pragya Ratan Sagar
  • 2. 1 Introduction All comparison operators produce true or false results. In other words, the comparison is either true or the comparison is false. The mathematical operators produce numeric values, whereas the comparison operators produce only true or false values. The rest of the program can use the true or false comparison operator result to make decisions. Comparison operators are operators that compare data values against each other and produce true or false results.
  • 3. 2 Decision Making Statements Decision Making Statements are of Two types:  The IF Statement If performs one of two possible code actions, depending on the result of the comparison.  Select Case statement Select case mainly used for multiple conditional statements or If we have a lot of conditional statements then we use Select Case Statement
  • 4. 3 The ‘IF’ Statement Perhaps the most important statement in a program is the If statement and then its statements. In other words, If uses comparison operator results to test data. If might execute one or more lines of subsequent code, depending on the result of a comparison.  In Visual Basic we use three types of ‘IF’ statements: 1. Simple IF 2. IF Else 3. Nested IF
  • 5. 4 Syntax of ‘IF’ statement in visual basic  Simple ‘IF’ : Simple IF used only for one condition. Syntax : If logical_expression Then One or more Visual Basic statements End If (block close) Example : Dim x As Integer Dim y As Integer x=3 y=4 If x > y Then MsgBox ("a is greater then b") Else MsgBox ("b is greater then a") End If
  • 6. 5  IF Else : Whereas If executes code based on the condition's true condition, the Else statement executes code based on the condition's false condition Syntax : If logical_expression Then One or more Visual Basic statements Else One or more Visual Basic statements End If Example : If (num > 0) Then Print “Number is Positive“ Else Print “Number is negative" End If
  • 7.  Nested IF : 6 Nested if used when we have more then one conditions to compare. Syntax : If logical_expression Then One or more Visual Basic statements Else If logical_epression Then One or more Visual Basic statements Else One or more Visual Basic statements End If Example : If temp < 0 Then Print “Too Cold” Else IF temp > 100 Then Print “Too Hot” Else Print “Temperature OK” End If
  • 8. 7 Select Case statement If we have a lot of conditional statements, using If..Then..Else could be very messy. For multiple conditional statements, it is better to use Select Case or Select Case allows multiway branching through the code.
  • 9. 8 Syntax for ‘Select Case’ statement in visual basic  Select Case : Syntax : Select Case expression ‘expression maybe string or numeric Case value1 Block of one or more VB statements Case value2 Block of one or more VB Statements Case value3 Block of one or more VB statements Case value4 . . . Case Else Block of one or more VB Statements End Select
  • 10. 9 Example : Select Case M Case 4,5 ‘months a and 5 Print “Spring” Case 6,7 ‘months 6 and 7 Print ‘Summer” Case 8 To 10 ‘months 8,9 and 10 Print “Autumn” Case 1 To 3,11,12 ‘months 1,2,3,11,12 Print “Winter” Case Else ‘not in range 1 To 12 Print M “is not recognised as a months” End Case
  • 11. VISUAL BASIC Decision Making Statements By Pragya Ratan Sagar