SlideShare a Scribd company logo
1 of 34
The Selection Structure
                    The if…then…Else and
                     Select Case Statement




Paramet Damchoo , lecturer
Business computer Department
Management science Faculty
Surattani ratjabhat University
The Selection Structure
You use the selection structure , also called
 the decision structure, when you want a
 program to make a decision or
 comparison and then, based on the result
 of that decision or comparison, to select
 one of two paths. You will need to use
 the selection structure to complete the
 Math application.
Figure 1-1: Decisions you might need to make today



        Example 1             Example 2
       If it’s raining then   If you have a test tomorrow then
         wear a rain coat      study tonight
        bring an umbrella     Otherwise
                               watch a movie
Coding the Selection Structure in
         Visual Basic
    • You use the if …then… Else
      statement to code the selection
      structure in Visual Basic. The syntax
      of the If…Then…Else statement is
      shown in figure 1-2
Figure 1-2: Syntax of If…Then…Else…Statement


If Condition Then
     [instructions when the condition is true]
Else
      [instructions when the condition is false]
End If
Figure1-3: lists the relational operators you can use
   in the If…Then..Else statement ‘s condition

Relational Operator        Meaning
=                          Equal to
>                          Greater than
>=                         Greater than or equal to
<                          Less than
<=                         Less than or equal to
<>                         Not equal to
Logical Operation
        AND                  OR                  XOR
True    True True    Tru   True   True   True    Tru False
True    Fals False   e
                     Tru   False True    True    e
                                                 Fal True
        e            e                           se
False   True False   Fals True True      False   Tru True
                     e                           e
False   Fals False   Fals False False    False   Fal False
        e            e                           se
         Not
                      AND
True    False
True    False
                           OR
False
False
                                  XOR
Example 1



     (Tax)
                   (Salary)

  20000                 15%
                       20000
             10%
Condition

                      Salary
                                               
   
Salary >= 20000                    Salary < 20000



 Tax = Salary * 15%            Tax = Salary * 10%


                                 CONDITION
•                    condition

                                 1 Condition
         syntax
               If Condition Then
                    [instructions when the
    condition is true]
              Else
                 [instructions when the
CONDITION



IF Salary >=       IF Salary < 20000
                     THEN
  20000 THEN
                       Tax = Salary *
    Tax = Salary     10%
  * 15%            ELSE
ELSE                  Tax = Salary *
   Tax = Salary      15%
  * 10%
Problem
Problem Definition
  Process
     Tax= Salary * 15%
     Tax = Salary * 10%
  Input
     Salary
     Single
  Output
     Tax             Single
Algorithm
1.
2.
3.
                 > = 20000

             =        x 15%

             =         x 10%
     4.
     5.
START

     Flowchart
                                 INPUT Salary

1.
2.
                                   Salary
3.                                >=20000
                  >=
          20000          =
                                                   =
                                                       x
                             x
             =         10%
                                                 15%
          x 15%

              =                  OUTPUT Salary

          x 10%
     4.                            STOP

     5.
Pseudo code
BEGIN
 Input Salary
    IF Salary >=20000 THEN
         Tax =Salary*(15/100)
    ELSE
         Tax =Salary*(10/100)
    END IF
DISPLAY Tax
END
Message Box 3. Title



                              1. Promt




                  Message    2.
2.                            Control
            Box
     Icon                     Msgbox
Syntax MessageBox



Msgbox Promt , Icon+Control+Default ,Title
Icon

VbCritical

VbExclam
ation
VbInform
ation
Vbquesti
on
VbOKOnly


VbokCancel


VbYesNo


VbYesNoCan
cel
coding




Msgb “                ,VbInformatio
                               +
ox              ”     n        VbYesnoCa
+ VbDefault2
        ,“
                               ncel
        MSGBOX”
Net IF statement
•                         2
                    IF

    (True/False)
Syntax
• IF Condition-1 THEN
      [instruction when condition is true]
  ELSEIF Condition-2 THEN
     [instruction when condition is true]
  ELSE
     [instruction when condition is false]
END IF
Example-1
•




    1       Freshman
    2       Sophomore
    3       Junior
    4       Senior
Condition
       IF Class = 1 THEN
         OUTPUT “Freshman “
       ELSEIF Class = 2 THEN
          OUTPUT “Sophomore”
       ELSEIF Class = 3 THEN
          OUTPUT “Junior”
       ELSEIF Class = 4 THEN
          OUTPUT “Senior”
       ELSE
         OUTPUT “Not is Student”
Problem Definition

     • INPUT
       – Class
          Integer
     • PROCESS
       – condition
     • OUTPUT
       –
Example-2

   (Book Shop)
   2

              (News paper)
                     (Magazine)
            5%
                Not Sale
                                  1
            News   paper    2
If statemet1
If statemet1
If statemet1
If statemet1
If statemet1

More Related Content

Recently uploaded

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
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
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc
 

Recently uploaded (20)

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Decarbonising Commercial Real Estate: The Role of Operational Performance
Decarbonising Commercial Real Estate: The Role of Operational PerformanceDecarbonising Commercial Real Estate: The Role of Operational Performance
Decarbonising Commercial Real Estate: The Role of Operational Performance
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
The Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightThe Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and Insight
 
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
 
Design and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data ScienceDesign and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data Science
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Choreo: Empowering the Future of Enterprise Software Engineering
Choreo: Empowering the Future of Enterprise Software EngineeringChoreo: Empowering the Future of Enterprise Software Engineering
Choreo: Empowering the Future of Enterprise Software Engineering
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
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
 
API Governance and Monetization - The evolution of API governance
API Governance and Monetization -  The evolution of API governanceAPI Governance and Monetization -  The evolution of API governance
API Governance and Monetization - The evolution of API governance
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Modernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using BallerinaModernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using Ballerina
 

Featured

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

If statemet1

  • 1. The Selection Structure The if…then…Else and Select Case Statement Paramet Damchoo , lecturer Business computer Department Management science Faculty Surattani ratjabhat University
  • 2. The Selection Structure You use the selection structure , also called the decision structure, when you want a program to make a decision or comparison and then, based on the result of that decision or comparison, to select one of two paths. You will need to use the selection structure to complete the Math application.
  • 3. Figure 1-1: Decisions you might need to make today Example 1 Example 2 If it’s raining then If you have a test tomorrow then wear a rain coat study tonight bring an umbrella Otherwise watch a movie
  • 4. Coding the Selection Structure in Visual Basic • You use the if …then… Else statement to code the selection structure in Visual Basic. The syntax of the If…Then…Else statement is shown in figure 1-2
  • 5. Figure 1-2: Syntax of If…Then…Else…Statement If Condition Then [instructions when the condition is true] Else [instructions when the condition is false] End If
  • 6. Figure1-3: lists the relational operators you can use in the If…Then..Else statement ‘s condition Relational Operator Meaning = Equal to > Greater than >= Greater than or equal to < Less than <= Less than or equal to <> Not equal to
  • 7. Logical Operation AND OR XOR True True True Tru True True True Tru False True Fals False e Tru False True True e Fal True e e se False True False Fals True True False Tru True e e False Fals False Fals False False False Fal False e e se Not AND True False True False OR False False XOR
  • 8. Example 1 (Tax) (Salary) 20000 15% 20000 10%
  • 9. Condition Salary   Salary >= 20000 Salary < 20000 Tax = Salary * 15% Tax = Salary * 10% CONDITION
  • 10. condition 1 Condition syntax If Condition Then [instructions when the condition is true] Else [instructions when the
  • 11. CONDITION IF Salary >= IF Salary < 20000 THEN 20000 THEN Tax = Salary * Tax = Salary 10% * 15% ELSE ELSE Tax = Salary * Tax = Salary 15% * 10%
  • 12. Problem Problem Definition Process  Tax= Salary * 15%  Tax = Salary * 10% Input  Salary Single Output  Tax Single
  • 13. Algorithm 1. 2. 3. > = 20000 = x 15% = x 10% 4. 5.
  • 14. START Flowchart INPUT Salary 1. 2. Salary 3. >=20000 >= 20000 = = x x = 10% 15% x 15% = OUTPUT Salary x 10% 4. STOP 5.
  • 15. Pseudo code BEGIN Input Salary IF Salary >=20000 THEN Tax =Salary*(15/100) ELSE Tax =Salary*(10/100) END IF DISPLAY Tax END
  • 16. Message Box 3. Title 1. Promt Message 2. 2. Control Box Icon Msgbox
  • 17. Syntax MessageBox Msgbox Promt , Icon+Control+Default ,Title
  • 20. coding Msgb “ ,VbInformatio + ox ” n VbYesnoCa + VbDefault2 ,“ ncel MSGBOX”
  • 21. Net IF statement • 2 IF (True/False)
  • 22. Syntax • IF Condition-1 THEN [instruction when condition is true] ELSEIF Condition-2 THEN [instruction when condition is true] ELSE [instruction when condition is false] END IF
  • 23. Example-1 • 1 Freshman 2 Sophomore 3 Junior 4 Senior
  • 24. Condition IF Class = 1 THEN OUTPUT “Freshman “ ELSEIF Class = 2 THEN OUTPUT “Sophomore” ELSEIF Class = 3 THEN OUTPUT “Junior” ELSEIF Class = 4 THEN OUTPUT “Senior” ELSE OUTPUT “Not is Student”
  • 25. Problem Definition • INPUT – Class Integer • PROCESS – condition • OUTPUT –
  • 26.
  • 27.
  • 28.
  • 29. Example-2 (Book Shop) 2 (News paper) (Magazine) 5% Not Sale 1 News paper 2