Conditional Statements - PowerPoint PPT Presentation

1 / 19
About This Presentation
Title:

Conditional Statements

Description:

Every type of data available in Visual Basic can be compared ... The Visual Basic IsNumeric function can check the input value to determine if ... – PowerPoint PPT presentation

Number of Views:26
Avg rating:3.0/5.0
Slides: 20
Provided by: bcps1
Category:

less

Transcript and Presenter's Notes

Title: Conditional Statements


1
Conditional Statements
2
Making Decisions with Conditional Statements
Using an IfThen Statement
  • A decision structure is one of the three
    fundamental control structures used in computer
    programming
  • When a condition is tested in a Visual Basic
    program, the condition either is true or false

3
Relational Operators
4
Comparing Strings
  • A string value comparison compares each character
    in two strings, starting with the first character
    in each string

5
Comparing Different Data Types
  • Every type of data available in Visual Basic can
    be compared
  • Different numeric types can be compared to each
    other
  • A single string character can be compared to a
    Char data type

6
Using the IfThenElse Statement
7
Using the IfThenElseIf Statement
8
Nested If Statements
9
Nested If Statements
10
Matching If, Else, and End If Entries
  • If statements must be fully contained within the
    outer If statement
  • Place the correct statements with the correct If
    and Else statements within the nested If
    statement
  • This illustration shows incorrect logic

11
Block-Level Scope
  • Scope is defined by where the variable is
    declared within a program
  • Within an event handler, an IfThenElse
    statement is considered a block of code
  • Variables can be declared within a block of code
  • The variable can be referenced only within the
    block of code where it is declared

12
Using Logical Operators
  • When more than one condition is included in an
    If...Then...Else statement, the conditions are
    called a compound condition

13
Using the And Logical Operator
14
Using the Or Logical Operator
15
Using the Not Logical Operator
A better option
16
Other Logical Operators
17
Order of Operations for Logical Operators
18
Testing Input to Determine If the Value Is
Numeric
  • The Visual Basic IsNumeric function can check the
    input value to determine if the value can be
    converted into a numeric value such as an Integer
    or Decimal data type

19
Checking for a Positive Number
Write a Comment
User Comments (0)
About PowerShow.com