SlideShare a Scribd company logo
1 of 11
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

Looping statement in vb.net
Looping statement in vb.netLooping statement in vb.net
Looping statement in vb.netilakkiya
 
Operating system and its function
Operating system and its functionOperating system and its function
Operating system and its functionNikhi Jain
 
python presentation
python presentationpython presentation
python presentationVaibhavMawal
 
Command line arguments
Command line argumentsCommand line arguments
Command line argumentsAshok Raj
 
Python If Else | If Else Statement In Python | Edureka
Python If Else | If Else Statement In Python | EdurekaPython If Else | If Else Statement In Python | Edureka
Python If Else | If Else Statement In Python | EdurekaEdureka!
 
File handling in c
File handling in cFile handling in c
File handling in caakanksha s
 
Fundamentals of operating system
Fundamentals of operating systemFundamentals of operating system
Fundamentals of operating systemJayesh Chauhan
 
Functions Of Operating System
Functions Of Operating SystemFunctions Of Operating System
Functions Of Operating SystemDr.Suresh Isave
 
Event handling
Event handlingEvent handling
Event handlingswapnac12
 
Transactions and Concurrency Control
Transactions and Concurrency ControlTransactions and Concurrency Control
Transactions and Concurrency ControlDilum Bandara
 
Syntax directed translation
Syntax directed translationSyntax directed translation
Syntax directed translationAkshaya Arunan
 
Introduction to python programming
Introduction to python programmingIntroduction to python programming
Introduction to python programmingSrinivas Narasegouda
 

What's hot (20)

VB Script
VB ScriptVB Script
VB Script
 
Sdi & mdi
Sdi & mdiSdi & mdi
Sdi & mdi
 
Looping statement in vb.net
Looping statement in vb.netLooping statement in vb.net
Looping statement in vb.net
 
File handling in c
File handling in cFile handling in c
File handling in c
 
Operating system and its function
Operating system and its functionOperating system and its function
Operating system and its function
 
python presentation
python presentationpython presentation
python presentation
 
Client server architecture
Client server architectureClient server architecture
Client server architecture
 
Command line arguments
Command line argumentsCommand line arguments
Command line arguments
 
Python If Else | If Else Statement In Python | Edureka
Python If Else | If Else Statement In Python | EdurekaPython If Else | If Else Statement In Python | Edureka
Python If Else | If Else Statement In Python | Edureka
 
Pointers in C Programming
Pointers in C ProgrammingPointers in C Programming
Pointers in C Programming
 
File handling in c
File handling in cFile handling in c
File handling in c
 
Java Threads
Java ThreadsJava Threads
Java Threads
 
Fundamentals of operating system
Fundamentals of operating systemFundamentals of operating system
Fundamentals of operating system
 
Functions Of Operating System
Functions Of Operating SystemFunctions Of Operating System
Functions Of Operating System
 
Event handling
Event handlingEvent handling
Event handling
 
Transactions and Concurrency Control
Transactions and Concurrency ControlTransactions and Concurrency Control
Transactions and Concurrency Control
 
Syntax directed translation
Syntax directed translationSyntax directed translation
Syntax directed translation
 
Code generation
Code generationCode generation
Code generation
 
Introduction to python programming
Introduction to python programmingIntroduction to python programming
Introduction to python programming
 
File system
File systemFile system
File system
 

Similar to Vb decision making statements

Decision statements
Decision statementsDecision statements
Decision statementsJaya Kumari
 
Decision structures chpt_5
Decision structures chpt_5Decision structures chpt_5
Decision structures chpt_5cmontanez
 
Control Structures in Visual Basic
Control Structures in  Visual BasicControl Structures in  Visual Basic
Control Structures in Visual BasicTushar Jain
 
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 statementRahul Sharma
 
W4-DecisionMaking.pdf. python document. CS
W4-DecisionMaking.pdf. python document. CSW4-DecisionMaking.pdf. python document. CS
W4-DecisionMaking.pdf. python document. CSMalikaKhan21
 
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.pptxAqeelAbbas94
 
1.4 conditions and loops
1.4   conditions and loops1.4   conditions and loops
1.4 conditions and loopsallenbailey
 
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 statementsnobel mujuji
 
python conditional statement.pptx
python conditional statement.pptxpython conditional statement.pptx
python conditional statement.pptxDolchandra
 

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
 
Control Structures in Visual Basic
Control Structures in  Visual BasicControl Structures in  Visual Basic
Control Structures in Visual Basic
 
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
 
python conditional statement.pptx
python conditional statement.pptxpython conditional statement.pptx
python conditional statement.pptx
 

Recently uploaded

Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parentsnavabharathschool99
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfJemuel Francisco
 
Measures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped dataMeasures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped dataBabyAnnMotar
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfErwinPantujan2
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management SystemChristalin Nelson
 
ICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfVanessa Camilleri
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
Dust Of Snow By Robert Frost Class-X English CBSE
Dust Of Snow By Robert Frost Class-X English CBSEDust Of Snow By Robert Frost Class-X English CBSE
Dust Of Snow By Robert Frost Class-X English CBSEaurabinda banchhor
 
Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4JOYLYNSAMANIEGO
 
Millenials and Fillennials (Ethical Challenge and Responses).pptx
Millenials and Fillennials (Ethical Challenge and Responses).pptxMillenials and Fillennials (Ethical Challenge and Responses).pptx
Millenials and Fillennials (Ethical Challenge and Responses).pptxJanEmmanBrigoli
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4MiaBumagat1
 
Presentation Activity 2. Unit 3 transv.pptx
Presentation Activity 2. Unit 3 transv.pptxPresentation Activity 2. Unit 3 transv.pptx
Presentation Activity 2. Unit 3 transv.pptxRosabel UA
 
TEACHER REFLECTION FORM (NEW SET........).docx
TEACHER REFLECTION FORM (NEW SET........).docxTEACHER REFLECTION FORM (NEW SET........).docx
TEACHER REFLECTION FORM (NEW SET........).docxruthvilladarez
 

Recently uploaded (20)

Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parents
 
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptxFINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
 
Measures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped dataMeasures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped data
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management System
 
ICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdf
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
Dust Of Snow By Robert Frost Class-X English CBSE
Dust Of Snow By Robert Frost Class-X English CBSEDust Of Snow By Robert Frost Class-X English CBSE
Dust Of Snow By Robert Frost Class-X English CBSE
 
Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4
 
Millenials and Fillennials (Ethical Challenge and Responses).pptx
Millenials and Fillennials (Ethical Challenge and Responses).pptxMillenials and Fillennials (Ethical Challenge and Responses).pptx
Millenials and Fillennials (Ethical Challenge and Responses).pptx
 
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptxYOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4
 
Paradigm shift in nursing research by RS MEHTA
Paradigm shift in nursing research by RS MEHTAParadigm shift in nursing research by RS MEHTA
Paradigm shift in nursing research by RS MEHTA
 
Presentation Activity 2. Unit 3 transv.pptx
Presentation Activity 2. Unit 3 transv.pptxPresentation Activity 2. Unit 3 transv.pptx
Presentation Activity 2. Unit 3 transv.pptx
 
TEACHER REFLECTION FORM (NEW SET........).docx
TEACHER REFLECTION FORM (NEW SET........).docxTEACHER REFLECTION FORM (NEW SET........).docx
TEACHER REFLECTION FORM (NEW SET........).docx
 

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