1 / 69

# Programming with Microsoft Visual Fundamental 2008 Fourth Release.

88 views
Description
Programming with Microsoft Visual Essential 2008 Fourth Release Section Four The Determination Structure Seeing the Regularly scheduled Installment Mini-computer Application The Regularly scheduled Installment Mini-computer application utilizes the choice structure Reviewing the Regularly scheduled Installment Number cruncher Application (proceeded with)
Transcripts
Slide 1

Programming with Microsoft Visual Basic 2008 Fourth Edition Chapter Four The Selection Structure

Slide 2

Previewing the Monthly Payment Calculator Application The Monthly Payment Calculator application utilizes the choice structure Programming with Microsoft Visual Basic 2008, Fourth Edition

Slide 3

Previewing the Monthly Payment Calculator Application (proceeded with) Figure 4-2: Monthly installment sum appeared in the interface Programming with Microsoft Visual Basic 2008, Fourth Edition

Slide 4

Lesson An Objectives After considering Lesson A, you ought to have the capacity to: Write pseudocode for the choice structure Create a flowchart to assist you with arranging an applicationâs code Write an If...Then...Else proclamation Write code that uses examination administrators and legitimate administrators Change the instance of a string Determine the achievement of the TryParse strategy Programming with Microsoft Visual Basic 2008, Fourth Edition

Slide 5

The Selection Structure Selection structure : Chooses one of two ways taking into account condition Also called a choice structure Example: If representative works more than 40 hours, add extra time pay Condition : Expression assessing to genuine or false Four determination structures in Visual Basic: If, If/Else, If/ElseIf/Else, and Case Programming with Microsoft Visual Basic 2008, Fourth Edition

Slide 6

The Selection Structure (proceeded with) Figure 4-3: Selection structures you may utilize today Programming with Microsoft Visual Basic 2008, Fourth Edition

Slide 7

Writing Pseudocode for If and If/Else Selection Structures If choice structure : Contains one and only arrangement of directions Instructions are handled if the condition is genuine If/Else choice structure : Contains two arrangements of guidelines True way : Instruction set after genuine condition False way : Instruction set after false condition Programming with Microsoft Visual Basic 2008, Fourth Edition

Slide 8

Writing Pseudocode for If and If/Else Selection Structures (proceeded with) Figure 4-4: Examples of the If and If/Else choice structures written in pseudocode Programming with Microsoft Visual Basic 2008, Fourth Edition

Slide 9

Flowcharting the If and If/Else Selection Structures Flowchart : Uses institutionalized images demonstrating strides to be taken to finish an assignment Oval : Start/stop image Rectangle : Process image Parallelogram : Input/yield image Diamond : Decision image Used in both choice and redundancy structures Programming with Microsoft Visual Basic 2008, Fourth Edition

Slide 10

Coding the If and If/Else Selection Structures Ifâ¦Thenâ¦Else explanation : Used to code If and If/Else choices structures Syntax: If condition Then articulation hinder for genuine way [Else articulation obstruct for false way ] End If condition must be a Boolean expression that assesses to True or False Else provision is discretionary Programming with Microsoft Visual Basic 2008, Fourth Edition

Slide 11

Flowcharting the If and If/Else Selection Structures (proceeded with) Figure 4-5: Examples of the If and If/Else choice structures attracted flowchart structure Programming with Microsoft Visual Basic 2008, Fourth Edition

Slide 12

Comparison Operators Comparison (social) administrators: Used to test two things for uniformity or sorts of non-equity Always bring about a True or False esteem Rules for correlation administrators They don\'t have a request of priority They are assessed from left to right They are assessed after any math administrators in the expression Programming with Microsoft Visual Basic 2008, Fourth Edition

Slide 13

Comparison Operators (proceeded with) Figure 4-8: Evaluation ventures for an expression containing number-crunching and examination administrators Programming with Microsoft Visual Basic 2008, Fourth Edition

Slide 14

Using Comparison OperatorsâSwapping Numeric Values Sample application shows the most minimal and most elevated of two numbers entered by the client Programming with Microsoft Visual Basic 2008, Fourth Edition

Slide 15

Using Comparison OperatorsâSwapping Numeric Values (proceeded with) Figure 4-9: Sample keep running of the Lowest and Highest application Programming with Microsoft Visual Basic 2008, Fourth Edition

Slide 16

Using Comparison OperatorsâSwapping Numeric Values (proceeded with) Figure 4-10: Display buttonâs pseudocode demonstrating the If choice structure Programming with Microsoft Visual Basic 2008, Fourth Edition

Slide 17

Using Comparison OperatorsâSwapping Numeric Values (proceeded with) Figure 4-11: Display buttonâs flowchart demonstrating the If choice structure Programming with Microsoft Visual Basic 2008, Fourth Edition

Slide 18

Using Comparison OperatorsâSwapping Numeric Values (proceeded with) Figure 4-12: Display buttonâs Click occasion system demonstrating the If choice structure Programming with Microsoft Visual Basic 2008, Fourth Edition

Slide 19

Using Comparison OperatorsâSwapping Numeric Values (proceeded with) Values information by the client are put away in variables with methodology scope A brief variable is utilized when values must be swapped Declared inside of explanation piece Block scope : Restricts utilization of variable to explanation hinder in which it is proclaimed Programming with Microsoft Visual Basic 2008, Fourth Edition

Slide 20

Using Comparison OperatorsâSwapping Numeric Values (proceeded with) Figure 4-13: Illustration of the swapping idea Programming with Microsoft Visual Basic 2008, Fourth Edition

Slide 21

Using Comparison OperatorsâDisplaying the Sum or Difference Sample application that shows the entirety or contrast of two numbers entered by the client Programming with Microsoft Visual Basic 2008, Fourth Edition

Slide 22

Using Comparison OperatorsâDisplaying the Sum or Difference (proceeded with) Figure 4-14: Sample keep running of the Addition and Subtraction application Programming with Microsoft Visual Basic 2008, Fourth Edition

Slide 23

Using Comparison OperatorsâDisplaying the Sum or Difference (proceeded with) Figure 4-15: Calculate buttonâs pseudocode demonstrating the If/Else choice structure Programming with Microsoft Visual Basic 2008, Fourth Edition

Slide 24

Using Comparison OperatorsâDisplaying the Sum or Difference (proceeded with) Figure 4-16: Calculate buttonâs flowchart demonstrating the If/Else choice structure Programming with Microsoft Visual Basic 2008, Fourth Edition

Slide 25

Using Comparison OperatorsâDisplaying the Sum or Difference (proceeded with) Figure 4-17: Calculate buttonâs Click occasion system demonstrating the If/Else choice structure Programming with Microsoft Visual Basic 2008, Fourth Edition

Slide 26

Logical Operators Logical administrators : Used to make compound conditions Also called Boolean administrators Six consistent administrators in Visual Basic: And Or Not AndAlso OrElse Xor Programming with Microsoft Visual Basic 2008, Fourth Edition

Slide 27

Logical Operators (proceeded with) Figure 4-18: Listing and cases of intelligent administrators Programming with Microsoft Visual Basic 2008, Fourth Edition

Slide 28

Logical Operators (proceeded with) Truth tables : Show how coherent administrators are assessed Short circuit assessment : Bypasses assessment of condition when result can be resolved without it Operators utilizing procedure: AndAlso, OrElse Example: If state = "TN" AndAlso deals > 50000D Thenâ¦ If state is not TN, no compelling reason to assess deals > 50000D Programming with Microsoft Visual Basic 2008, Fourth Edition

Slide 29

Logical Operators (proceeded with) Figure 4-19: Truth tables for the coherent administrators Programming with Microsoft Visual Basic 2008, Fourth Edition

Slide 30

Logical Operators (proceeded with) Figure 4-19: Truth tables for the legitimate administrators (kept) Programming with Microsoft Visual Basic 2008, Fourth Edition

Slide 31

Logical Operators (proceeded with) Figure 4-19: Truth tables for the intelligent administrators (kept) Programming with Microsoft Visual Basic 2008, Fourth Edition

Slide 32

Using the Truth Tables Scenario: Calculate a reward for a salesman Bonus condition: âAâ rating and deals > \$10,000 Appropriate administrators: And, AndAlso (more productive) Both conditions must be consistent with get reward Sample code: rating = "A" AndAlso deals > 10000 Precedence of consistent administrators: Evaluated after any number-crunching or correlation administrators in the expression Programming with Microsoft Visual Basic 2008, Fourth Edition

Slide 33

Using Logical Operators: Calculating Gross Pay Data acceptance : Verifying that info information is inside expected extent Scenario: Calculate and show worker gross pay Requirements for application: Verify hours are inside of reach (>= 0.0 and <= 40.0) If information is substantial, ascertain and showcase gross pay If information is not substantial, show slip message Can perform this utilizing AndAlso or OrElse Programming with Microsoft Visual Basic 2008, Fourth Edition

Slide 34

Comparing Strings Containing Letters Scenario: Display âPassâ if âPâ is entered in txtLetter control Display âFailâ if âFâ is entered in txtLetter control Can utilize the OrElse or the AndAlso administrator Note that âPâ is not the same as âpâ They have diverse Unicode qualities Programming with Microsoft Visual Basic 2008, Fourth Edition

Slide 35

Comparing Strings Containing Letters (proceeded with) Figure 4-23: Visual Basic code indicating string correlations in the If...Then...Else statementâs condition Programming with Microsoft Visual Basic 2008, Fourth Edition

Slide 36

Comparing Strings Containing Letters (proceeded with) Figure 4-23: Visual Basic code indicating string correlations in the If...Then...Else statementâs condition (kept) Programming with Microsoft Visual Basic 2008, Fourth Edition .

Recommended
View more...