Upcoming SlideShare
Loading in...5

Like this? Share it with your network

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads


Total Views
On Slideshare
From Embeds
Number of Embeds



Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

    No notes for slide


  • 1. Making Decisions VB.NET 1
  • 2. ObjectivesUnderstand how relational operators areused to create a conditionUnderstand and use IF statements,including nested IF statementsUnderstand and use compound conditionsDevelop and evaluate multiple solutions tothe same problemSuccessfully write program solutions thatrequire decision making 2
  • 3. Selection StatementsThe most common decision structure is the IF statement.A condition is a boolean expression that evaluates to eithertrue or false.Comparison operators require numeric operands andproduce a logical result.Conditions typically involve one of six relational operators. Greater than > Less than < Greater than or equal >= Less than or equal <= Equal = Not equal <> 3
  • 4. The IF Statement Conditions 4
  • 5. Simple IF Statements (design)Decision symbol Process symbol 5
  • 6. Solving the Overtime Problem 6
  • 7. code ExamplePrivate Sub btnCheck_Click() Dim Input, value1, value2 As Integer If Input = value1 Then ‘ Condition 1 is True process A ‘so only this code runs ElseIf Input = value2 Then ‘ Condition 2 is True process B ‘different response Else ‘ Neither condition is True process C ‘can be error message End IfEnd Sub Task 1: Create programs to perform the functions shown in the flow chart examples. Task 2: Create a version(2) of the Correct Change program (from Input/Output) using selection statements. 7
  • 8. Nested IF Statements (design)The term nested IF refers toan IF statement containedwithin the true or falsebranch of another IFstatement. 8
  • 9. True OR False Conditions 9
  • 10. Compound ConditionsA compound condition consists of twoconditions within parentheses joined by alogical operator.Logical Operators require logical operandsand produce a logical result. NOT Logical opposite AND Both values are true OR At least one value is true XOR Exactly one value is true 10
  • 11. Logical Operators 11
  • 12. Operator PrecedenceWhen several operations occur in anexpression, each part is evaluated andresolved in a predetermined order calledoperator precedence. 1st : Evaluate all arithmetic/concatenation operators 2nd : Evaluate all comparison operators 3rd : Evaluate all logical operators 12
  • 13. The Select…..Case StatementWhen more choices are available use theSelect – Case statement, an example isshown below. 13
  • 14. SummaryA condition is an expression that evaluatesto either true or false.IF statements use conditions to choosebetween actions.The true and false branches of an IFstatement may contain any valid statement,including other IF statements.A compound condition is two or moreconditions joined by a logical operator. 14