SlideShare a Scribd company logo
1 of 26
Working with
        Comparison
         Operators


Jesselle Capa

Charles Justine Bool
Comparison Operators
Operators that compare data values
  to produce true or false results.



            ASCII
 Contains a list of characters with
  corresponding unique numeric
         representation
Comparison Operators
Operator         Usage                           Description
   >       lblSales.Caption >   The greater than operator return True Only
           Goal                 if the value on the right.
   <       Pay < 2000.0         The less than operator return True if the
                                value on the left of < is less than the value
                                on the right.
   =       Age = Limit          The equal to operator return True if the
                                value on the both sides of = are equal.
  >=       FirstName >=         The greater than or equal to operator
           “Mike”               return True if the value on the left of >= is
                                greater than or equal to the value on the
                                right.
  <=       Num <=               The less than or equal to operator return
           lblAmt.Caption       True if the value on the left of <= is less
                                than or equal to the value on the right.
  <>       txtAns.text<>        The not equal to operator return True if the
           “Yes”                value on the left of <> is unequal to the
                                value on the right.
Relationship Results
        Relation             Result
          2>1                 True
          3<3                False
         5 > 10               True
   “Apple” <= “Orange”        True
“Macdonald “ < “Mc Donald”    True
          0 >=0               True
          0 <=0               True
          1 <>2               True
          2 >=3              False
Working with If Statement
   The If statement provides logic for the
    application, w/c analyzes data and makes
    decisions based on the analysis.

   The If statement uses comparison operators
    to test data values and performs one of two
    possible actions based on the results of the
    comparison‟s test.

   Without the If statement, the application
    code will sequentially execute . Meaning , one
    statement is executed after another.
The If statement is usually
written in the following
format:

     If comparisonTest Then

          One or more statements

     End If
If Statement and Comparison
   Keep in mind that the body of the If
    statement executes based on the results of
    the comparison test. The statement executes
    if the results is true. Otherwise , the rest of
    the application executes as usual and the If
    statement will be skipped.

   Data that are entered into a text box control
    is treated as a Variant data type . When
    arithmetic is performed with a Variant with
    data type that holds a numeric value . Visual
    Basic will convert such data to a number for
    the calculation purposes.
The If statement's Else Branching

   The If statement with Else is usually written in
    the following format:

            If comparisontest Then

                   one   or   more statements

            Else

                   one   or   more statements

            End If
Compound Comparison with the
         Logical Operators

Operator         Usage                  Description


  And      If (A > B) And (C <   Returns True if both sides
                    D)           of the And are true.


   Or      If (A > B) Or (C <    Returns True if either side
                   D)            of the Or is true.



  Not        If Not (strAns =    Returns the opposite true
                   “Yes”)        or false result.
Example :
Private Sub cmdGetStudentGrade_Click()

„Code for Generating Student's Grade
„Declare Variables
Dim percent As Integer, studentmark As String

„Clear text Box
   txtGrade.Text = ""

„Get Students Mark from inputbox
   percent = InputBox("Enter Students
  Percent")
'Begin if statement
   If percent >= 50 And percent < 60 Then
      studentmark = "C"
   Else percent >= 60 And percent < 70 Then
      studentmark = "B"
   Else percent >= 70 Then
      studentmark = "A"
   Else
      studentmark = "FAIL"
   End If

'Display Output
   txtGrade.Text = studentmark
End Sub
Nesting If-Else Statements

If (intAge = 5) Then
  lblTitle.Caption = “Kindergarten”
Else
  If (intAge = 6) Then
      lblTitle.Caption = “1st Grade”
  Else
      If (intAge = 7) Then
            lblTitle.Caption = “2nd Grade”
If (intAge = 8) Then
      lblTitle.Caption = “3rd Grade”
Else
     If (intAge = 9) Then
           lblTitle.Caption = “4th Grade”
     Else
          If (intAge = 10) Then
              lblTitle.Caption = “5th Grade”
          Else
               If (intAge = 11) Then
                  lblTitle.Caption = “6th Grade”
               Else
lblTitle.Caption   = "Advanced"
                 End If
             End If
          End If
       End If
     End If
  End If
End If
Using Select Case Statement
   The Select Case Statement handles multiple –
    choice conditions better than If-Else . When
    several choices are possible , programmers
    usually use Select Case as a substitute for
    long , nested If-Else , but you may find out
    that it is easier to code and to maintain .
    However , you must avoid using the Select
    Case if you will have a simple If or If-
    Else for the code , unless you need to
    compare against more than two values .
    Otherwise , stick with the simple If and If-
    Else statements
Select Case intAge
 Case 5 : lblTitle.Caption = "Kindergarten"
 Case 6 : lblTitle.Caption = "1st Grade"
 Case 7 : lblTitle.Caption = "2nd Grade"
 Case 8 : lblTitle.Caption = "3rd Grade"
 Case 9 : lblTitle.Caption = "4th Grade"
 Case 10 : lblTitle.Caption = "5th Grade
 Case 11 : lblTitle.Caption = "6th Grade
 Case Else : lblTitle.Caption = "Advanced"
End Select
3 Select Case Optional Formats:
   Select Case Expressions
    Case Is Relation :
       One or more Statements
     Case Is Relation :
       One or more Statements
    [Case Is Relation :
       One or more Statements]
    [Case Is Relation :
       One or more Statements]
   End Else
Select Case Expressions
 Case Value
     One or more Visual   Basic Statements
 Case Value
     One or more Visual   Basic Statements
 [Case Value
     One or more Visual   Basic Statements]
 [Case Value
     One or more Visual   Basic Statements]

End Else
Select Case Expressions

   Case expr1 To expr2 :
     One or more Visual Basic   Statements
   Case expr1 To expr2 :
     One or more Visual Basic   Statements
   [Case expr1 To expr2 :
     One or more Visual Basic   Statements]
   [Case Else :
     One or more Visual Basic   Statements]

End Else
Working with comparison operators
Working with comparison operators
Working with comparison operators
Working with comparison operators

More Related Content

What's hot

sparse matrix in data structure
sparse matrix in data structuresparse matrix in data structure
sparse matrix in data structureMAHALAKSHMI P
 
oops concept in java | object oriented programming in java
oops concept in java | object oriented programming in javaoops concept in java | object oriented programming in java
oops concept in java | object oriented programming in javaCPD INDIA
 
Digital logic design lecture 01
Digital logic design   lecture 01Digital logic design   lecture 01
Digital logic design lecture 01FarhatUllah27
 
STACKS IN DATASTRUCTURE
STACKS IN DATASTRUCTURESTACKS IN DATASTRUCTURE
STACKS IN DATASTRUCTUREArchie Jamwal
 
Interpolation and its applications
Interpolation and its applicationsInterpolation and its applications
Interpolation and its applicationsRinkuMonani
 
Applications of analytic functions and vector calculus
Applications of analytic functions and vector calculusApplications of analytic functions and vector calculus
Applications of analytic functions and vector calculusPoojith Chowdhary
 
Newton’s Forward & backward interpolation
Newton’s Forward &  backward interpolation Newton’s Forward &  backward interpolation
Newton’s Forward & backward interpolation Meet Patel
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlabSantosh V
 
An Introduction to Deep Learning
An Introduction to Deep LearningAn Introduction to Deep Learning
An Introduction to Deep LearningPoo Kuan Hoong
 
C language introduction geeksfor geeks
C language introduction   geeksfor geeksC language introduction   geeksfor geeks
C language introduction geeksfor geeksAashutoshChhedavi
 
Fuzzy logic-introduction
Fuzzy logic-introductionFuzzy logic-introduction
Fuzzy logic-introductionWBUTTUTORIALS
 
Effective Algorithm for n Fibonacci Number By: Professor Lili Saghafi
Effective Algorithm for n Fibonacci Number By: Professor Lili SaghafiEffective Algorithm for n Fibonacci Number By: Professor Lili Saghafi
Effective Algorithm for n Fibonacci Number By: Professor Lili SaghafiProfessor Lili Saghafi
 
Activation function
Activation functionActivation function
Activation functionAstha Jain
 
Gauss Elimination & Gauss Jordan Methods in Numerical & Statistical Methods
Gauss Elimination & Gauss Jordan Methods in Numerical & Statistical MethodsGauss Elimination & Gauss Jordan Methods in Numerical & Statistical Methods
Gauss Elimination & Gauss Jordan Methods in Numerical & Statistical MethodsJanki Shah
 

What's hot (20)

sparse matrix in data structure
sparse matrix in data structuresparse matrix in data structure
sparse matrix in data structure
 
Graph traversals in Data Structures
Graph traversals in Data StructuresGraph traversals in Data Structures
Graph traversals in Data Structures
 
oops concept in java | object oriented programming in java
oops concept in java | object oriented programming in javaoops concept in java | object oriented programming in java
oops concept in java | object oriented programming in java
 
Double Integrals
Double IntegralsDouble Integrals
Double Integrals
 
Fractional knapsack problem
Fractional knapsack problemFractional knapsack problem
Fractional knapsack problem
 
Python tuple
Python   tuplePython   tuple
Python tuple
 
Digital logic design lecture 01
Digital logic design   lecture 01Digital logic design   lecture 01
Digital logic design lecture 01
 
2d transformations
2d transformations2d transformations
2d transformations
 
STACKS IN DATASTRUCTURE
STACKS IN DATASTRUCTURESTACKS IN DATASTRUCTURE
STACKS IN DATASTRUCTURE
 
Interpolation and its applications
Interpolation and its applicationsInterpolation and its applications
Interpolation and its applications
 
Applications of analytic functions and vector calculus
Applications of analytic functions and vector calculusApplications of analytic functions and vector calculus
Applications of analytic functions and vector calculus
 
Newton’s Forward & backward interpolation
Newton’s Forward &  backward interpolation Newton’s Forward &  backward interpolation
Newton’s Forward & backward interpolation
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
 
An Introduction to Deep Learning
An Introduction to Deep LearningAn Introduction to Deep Learning
An Introduction to Deep Learning
 
C language introduction geeksfor geeks
C language introduction   geeksfor geeksC language introduction   geeksfor geeks
C language introduction geeksfor geeks
 
Fuzzy logic-introduction
Fuzzy logic-introductionFuzzy logic-introduction
Fuzzy logic-introduction
 
Effective Algorithm for n Fibonacci Number By: Professor Lili Saghafi
Effective Algorithm for n Fibonacci Number By: Professor Lili SaghafiEffective Algorithm for n Fibonacci Number By: Professor Lili Saghafi
Effective Algorithm for n Fibonacci Number By: Professor Lili Saghafi
 
Activation function
Activation functionActivation function
Activation function
 
Gauss Elimination & Gauss Jordan Methods in Numerical & Statistical Methods
Gauss Elimination & Gauss Jordan Methods in Numerical & Statistical MethodsGauss Elimination & Gauss Jordan Methods in Numerical & Statistical Methods
Gauss Elimination & Gauss Jordan Methods in Numerical & Statistical Methods
 
Data Structure (Tree)
Data Structure (Tree)Data Structure (Tree)
Data Structure (Tree)
 

Similar to Working with comparison operators

03a control structures
03a   control structures03a   control structures
03a control structuresManzoor ALam
 
CIS 1403 lab 4 selection
CIS 1403 lab 4 selectionCIS 1403 lab 4 selection
CIS 1403 lab 4 selectionHamad Odhabi
 
11-ScriptsAndConditionals.ppt
11-ScriptsAndConditionals.ppt11-ScriptsAndConditionals.ppt
11-ScriptsAndConditionals.pptAnjali127411
 
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
 
Ap Power Point Chpt3 B
Ap Power Point Chpt3 BAp Power Point Chpt3 B
Ap Power Point Chpt3 Bdplunkett
 
FLOW OF CONTROL-INTRO PYTHON
FLOW OF CONTROL-INTRO PYTHONFLOW OF CONTROL-INTRO PYTHON
FLOW OF CONTROL-INTRO PYTHONvikram mahendra
 
conditional statements.docx
conditional statements.docxconditional statements.docx
conditional statements.docxssuser2e84e4
 
05. Conditional Statements
05. Conditional Statements05. Conditional Statements
05. Conditional StatementsIntro C# Book
 
Absolute Java 5e Savitch Test Bank
Absolute Java 5e Savitch Test BankAbsolute Java 5e Savitch Test Bank
Absolute Java 5e Savitch Test BankLauriewest24
 
Loops and conditional statements
Loops and conditional statementsLoops and conditional statements
Loops and conditional statementsSaad Sheikh
 

Similar to Working with comparison operators (20)

03a control structures
03a   control structures03a   control structures
03a control structures
 
Perl_Part2
Perl_Part2Perl_Part2
Perl_Part2
 
CIS 1403 lab 4 selection
CIS 1403 lab 4 selectionCIS 1403 lab 4 selection
CIS 1403 lab 4 selection
 
Chapter 04
Chapter 04Chapter 04
Chapter 04
 
11-ScriptsAndConditionals.ppt
11-ScriptsAndConditionals.ppt11-ScriptsAndConditionals.ppt
11-ScriptsAndConditionals.ppt
 
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
 
Using decision statements
Using decision statementsUsing decision statements
Using decision statements
 
Ch05-converted.pptx
Ch05-converted.pptxCh05-converted.pptx
Ch05-converted.pptx
 
Ch05.pdf
Ch05.pdfCh05.pdf
Ch05.pdf
 
MS Excel 2010 tutorial 5
MS Excel 2010 tutorial 5MS Excel 2010 tutorial 5
MS Excel 2010 tutorial 5
 
Ap Power Point Chpt3 B
Ap Power Point Chpt3 BAp Power Point Chpt3 B
Ap Power Point Chpt3 B
 
Control All
Control AllControl All
Control All
 
Lecture 2
Lecture 2Lecture 2
Lecture 2
 
FLOW OF CONTROL-INTRO PYTHON
FLOW OF CONTROL-INTRO PYTHONFLOW OF CONTROL-INTRO PYTHON
FLOW OF CONTROL-INTRO PYTHON
 
Chap 4 c++
Chap 4 c++Chap 4 c++
Chap 4 c++
 
conditional statements.docx
conditional statements.docxconditional statements.docx
conditional statements.docx
 
05. Conditional Statements
05. Conditional Statements05. Conditional Statements
05. Conditional Statements
 
Absolute Java 5e Savitch Test Bank
Absolute Java 5e Savitch Test BankAbsolute Java 5e Savitch Test Bank
Absolute Java 5e Savitch Test Bank
 
Loops and conditional statements
Loops and conditional statementsLoops and conditional statements
Loops and conditional statements
 

More from Sara Corpuz

Title, heading and paragraph tags
Title, heading and paragraph tagsTitle, heading and paragraph tags
Title, heading and paragraph tagsSara Corpuz
 
Creating your 1st html page
Creating your 1st html pageCreating your 1st html page
Creating your 1st html pageSara Corpuz
 
Visual basic coding
Visual basic codingVisual basic coding
Visual basic codingSara Corpuz
 
Program logic formulation
Program logic formulationProgram logic formulation
Program logic formulationSara Corpuz
 
Flowcharting and pseudocoding
Flowcharting and pseudocodingFlowcharting and pseudocoding
Flowcharting and pseudocodingSara Corpuz
 
Working with visual basic applications
Working with visual basic applicationsWorking with visual basic applications
Working with visual basic applicationsSara Corpuz
 
Building visual basic application
Building visual basic applicationBuilding visual basic application
Building visual basic applicationSara Corpuz
 

More from Sara Corpuz (9)

Title, heading and paragraph tags
Title, heading and paragraph tagsTitle, heading and paragraph tags
Title, heading and paragraph tags
 
Creating your 1st html page
Creating your 1st html pageCreating your 1st html page
Creating your 1st html page
 
Visual basic coding
Visual basic codingVisual basic coding
Visual basic coding
 
Program logic formulation
Program logic formulationProgram logic formulation
Program logic formulation
 
Flowcharting and pseudocoding
Flowcharting and pseudocodingFlowcharting and pseudocoding
Flowcharting and pseudocoding
 
Working with visual basic applications
Working with visual basic applicationsWorking with visual basic applications
Working with visual basic applications
 
Building visual basic application
Building visual basic applicationBuilding visual basic application
Building visual basic application
 
Visual basic
Visual basicVisual basic
Visual basic
 
Logic
LogicLogic
Logic
 

Recently uploaded

The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 

Recently uploaded (20)

The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 

Working with comparison operators

  • 1. Working with Comparison Operators Jesselle Capa Charles Justine Bool
  • 2. Comparison Operators Operators that compare data values to produce true or false results. ASCII Contains a list of characters with corresponding unique numeric representation
  • 3. Comparison Operators Operator Usage Description > lblSales.Caption > The greater than operator return True Only Goal if the value on the right. < Pay < 2000.0 The less than operator return True if the value on the left of < is less than the value on the right. = Age = Limit The equal to operator return True if the value on the both sides of = are equal. >= FirstName >= The greater than or equal to operator “Mike” return True if the value on the left of >= is greater than or equal to the value on the right. <= Num <= The less than or equal to operator return lblAmt.Caption True if the value on the left of <= is less than or equal to the value on the right. <> txtAns.text<> The not equal to operator return True if the “Yes” value on the left of <> is unequal to the value on the right.
  • 4. Relationship Results Relation Result 2>1 True 3<3 False 5 > 10 True “Apple” <= “Orange” True “Macdonald “ < “Mc Donald” True 0 >=0 True 0 <=0 True 1 <>2 True 2 >=3 False
  • 5. Working with If Statement  The If statement provides logic for the application, w/c analyzes data and makes decisions based on the analysis.  The If statement uses comparison operators to test data values and performs one of two possible actions based on the results of the comparison‟s test.  Without the If statement, the application code will sequentially execute . Meaning , one statement is executed after another.
  • 6. The If statement is usually written in the following format: If comparisonTest Then One or more statements End If
  • 7. If Statement and Comparison  Keep in mind that the body of the If statement executes based on the results of the comparison test. The statement executes if the results is true. Otherwise , the rest of the application executes as usual and the If statement will be skipped.  Data that are entered into a text box control is treated as a Variant data type . When arithmetic is performed with a Variant with data type that holds a numeric value . Visual Basic will convert such data to a number for the calculation purposes.
  • 8. The If statement's Else Branching  The If statement with Else is usually written in the following format: If comparisontest Then one or more statements Else one or more statements End If
  • 9. Compound Comparison with the Logical Operators Operator Usage Description And If (A > B) And (C < Returns True if both sides D) of the And are true. Or If (A > B) Or (C < Returns True if either side D) of the Or is true. Not If Not (strAns = Returns the opposite true “Yes”) or false result.
  • 10. Example : Private Sub cmdGetStudentGrade_Click() „Code for Generating Student's Grade „Declare Variables Dim percent As Integer, studentmark As String „Clear text Box txtGrade.Text = "" „Get Students Mark from inputbox percent = InputBox("Enter Students Percent")
  • 11. 'Begin if statement If percent >= 50 And percent < 60 Then studentmark = "C" Else percent >= 60 And percent < 70 Then studentmark = "B" Else percent >= 70 Then studentmark = "A" Else studentmark = "FAIL" End If 'Display Output txtGrade.Text = studentmark End Sub
  • 12.
  • 13.
  • 14.
  • 15. Nesting If-Else Statements If (intAge = 5) Then lblTitle.Caption = “Kindergarten” Else If (intAge = 6) Then lblTitle.Caption = “1st Grade” Else If (intAge = 7) Then lblTitle.Caption = “2nd Grade”
  • 16. If (intAge = 8) Then lblTitle.Caption = “3rd Grade” Else If (intAge = 9) Then lblTitle.Caption = “4th Grade” Else If (intAge = 10) Then lblTitle.Caption = “5th Grade” Else If (intAge = 11) Then lblTitle.Caption = “6th Grade” Else
  • 17. lblTitle.Caption = "Advanced" End If End If End If End If End If End If End If
  • 18. Using Select Case Statement  The Select Case Statement handles multiple – choice conditions better than If-Else . When several choices are possible , programmers usually use Select Case as a substitute for long , nested If-Else , but you may find out that it is easier to code and to maintain . However , you must avoid using the Select Case if you will have a simple If or If- Else for the code , unless you need to compare against more than two values . Otherwise , stick with the simple If and If- Else statements
  • 19. Select Case intAge Case 5 : lblTitle.Caption = "Kindergarten" Case 6 : lblTitle.Caption = "1st Grade" Case 7 : lblTitle.Caption = "2nd Grade" Case 8 : lblTitle.Caption = "3rd Grade" Case 9 : lblTitle.Caption = "4th Grade" Case 10 : lblTitle.Caption = "5th Grade Case 11 : lblTitle.Caption = "6th Grade Case Else : lblTitle.Caption = "Advanced" End Select
  • 20. 3 Select Case Optional Formats: Select Case Expressions Case Is Relation : One or more Statements Case Is Relation : One or more Statements [Case Is Relation : One or more Statements] [Case Is Relation : One or more Statements] End Else
  • 21. Select Case Expressions Case Value One or more Visual Basic Statements Case Value One or more Visual Basic Statements [Case Value One or more Visual Basic Statements] [Case Value One or more Visual Basic Statements] End Else
  • 22. Select Case Expressions Case expr1 To expr2 : One or more Visual Basic Statements Case expr1 To expr2 : One or more Visual Basic Statements [Case expr1 To expr2 : One or more Visual Basic Statements] [Case Else : One or more Visual Basic Statements] End Else