1 / 50

Microsoft Visual Basic 2008: Reloaded Third Edition

Microsoft Visual Basic 2008: Reloaded, Third Edition. 2. Objectives. After studying this chapter, you should be able to:Include the Do loop in both pseudocode and a flowchartWrite a Do

amma
Télécharger la présentation

Microsoft Visual Basic 2008: Reloaded Third Edition

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


    1. Microsoft Visual Basic 2008: Reloaded Third Edition Chapter Six The Do Loop and List Boxes

    2. Microsoft Visual Basic 2008: Reloaded, Third Edition 2 Objectives After studying this chapter, you should be able to: Include the Do loop in both pseudocode and a flowchart Write a Do…Loop statement Initialize counters and accumulators Display a dialog box using the InputBox function Refresh the screen

    3. Microsoft Visual Basic 2008: Reloaded, Third Edition 3 Objectives (continued) Delay program execution Enable and disable a control

    4. Microsoft Visual Basic 2008: Reloaded, Third Edition 4 The Repetition Structure Repetition structure (or loop): a structure that repeatedly processes one or more program instructions until a condition is met Pretest loop The condition is evaluated before the instructions within the loop are processed The instructions may be processed zero or more times Posttest loop The condition is evaluated after the instructions within the loop are processed The instructions are always processed at least once

    5. Microsoft Visual Basic 2008: Reloaded, Third Edition 5 The Repetition Structure (continued) Repetition statements in Visual Basic Do...Loop For...Next For Each...Next

    6. Microsoft Visual Basic 2008: Reloaded, Third Edition 6 The Do...Loop Statement Do...Loop statement: codes both a pretest or posttest loop Use While or Until to code the condition for the loop Repetition symbol in a flowchart is the diamond

    7. Microsoft Visual Basic 2008: Reloaded, Third Edition 7 The Do...Loop Statement (continued)

    8. Microsoft Visual Basic 2008: Reloaded, Third Edition 8 The Do...Loop Statement (continued)

    9. The Do...Loop Statement (continued) Microsoft Visual Basic 2008: Reloaded, Third Edition 9

    10. Microsoft Visual Basic 2008: Reloaded, Third Edition 10 The Do...Loop Statement (continued)

    11. Microsoft Visual Basic 2008: Reloaded, Third Edition 11 The Do...Loop Statement (continued)

    12. Microsoft Visual Basic 2008: Reloaded, Third Edition 12 The Do...Loop Statement (continued)

    13. Microsoft Visual Basic 2008: Reloaded, Third Edition 13 The Do...Loop Statement (continued)

    14. Microsoft Visual Basic 2008: Reloaded, Third Edition 14 Using Counters and Accumulators Counter: a numeric variable used for counting Accumulator: a numeric variable used for accumulating (adding together) Initializing: assigning a beginning value to a counter or accumulator variable Updating (or incrementing): adding a number to the value of a counter or accumulator variable Counters are always incremented by a constant value, usually 1

    15. Microsoft Visual Basic 2008: Reloaded, Third Edition 15 The InputBox Function Function: a predefined procedure that performs a specific task and returns a value InputBox function: displays a predefined dialog box that allows the user to enter data Contains a text message, an OK button, a Cancel button, and an input area InputBox function returns: The user’s entry if the user clicks the OK button An empty string if the user clicks the Cancel button or the Close button on the title bar

    16. Microsoft Visual Basic 2008: Reloaded, Third Edition 16 The InputBox Function (continued)

    17. Microsoft Visual Basic 2008: Reloaded, Third Edition 17 The InputBox Function (continued)

    18. Microsoft Visual Basic 2008: Reloaded, Third Edition 18 The InputBox Function (continued)

    19. Microsoft Visual Basic 2008: Reloaded, Third Edition 19 The InputBox Function (continued)

    20. Microsoft Visual Basic 2008: Reloaded, Third Edition 20 The Sales Express Application

    21. Microsoft Visual Basic 2008: Reloaded, Third Edition 21 The Sales Express Application (continued)

    22. Microsoft Visual Basic 2008: Reloaded, Third Edition 22 The Sales Express Application (continued)

    23. Microsoft Visual Basic 2008: Reloaded, Third Edition 23

    24. Microsoft Visual Basic 2008: Reloaded, Third Edition 24 Using a List Box in an Interface List box: displays a list of choices from which the user can select zero or more choices SelectionMode property: controls the number of choices a user can select None: user can scroll but not select anything One: user can select one item MultiSimple and MultiExtended: user can select multiple items

    25. Microsoft Visual Basic 2008: Reloaded, Third Edition 25 Adding Items to a List Box Items collection: a collection of the items in a list box Collection: a group of one or more individual objects treated as one unit Add method: adds an item to the list box’s Items collection Items to be added must be converted to String Load event of a form: occurs when an application is started and the form is displayed for the first time

    26. Microsoft Visual Basic 2008: Reloaded, Third Edition 26 Adding Items to a List Box (continued)

    27. Microsoft Visual Basic 2008: Reloaded, Third Edition 27 Adding Items to a List Box (continued)

    28. Microsoft Visual Basic 2008: Reloaded, Third Edition 28 Adding Items to a List Box (continued) Sorted property: Determines if the list box items are sorted Sort order is dictionary order

    29. Accessing Items in a List Box Index: A unique number that identifies an item in a collection Is zero-relative: the first item has index of 0 Microsoft Visual Basic 2008: Reloaded, Third Edition 29

    30. Accessing Items in a List Box (continued) Microsoft Visual Basic 2008: Reloaded, Third Edition 30

    31. Determining the Number of Items in a List Box Items.Count property: stores the number of items in a list box Count value is always one higher than the highest index in the list box Microsoft Visual Basic 2008: Reloaded, Third Edition 31

    32. Microsoft Visual Basic 2008: Reloaded, Third Edition 32

    33. Microsoft Visual Basic 2008: Reloaded, Third Edition 33 The SelectedItem and SelectedIndex Properties SelectedItem property: Contains the value of the selected item in the list If nothing is selected, it contains the empty string SelectedIndex property: Contains the index of the selected item in the list If nothing is selected, it contains the value -1 Default list box item: the item that is selected by default when the interface first appears

    34. Microsoft Visual Basic 2008: Reloaded, Third Edition 34

    35. Microsoft Visual Basic 2008: Reloaded, Third Edition 35

    36. Microsoft Visual Basic 2008: Reloaded, Third Edition 36

    37. Microsoft Visual Basic 2008: Reloaded, Third Edition 37

    38. Microsoft Visual Basic 2008: Reloaded, Third Edition 38

    39. Microsoft Visual Basic 2008: Reloaded, Third Edition 39 The SelectedValueChanged and SelectedIndexChanged Events (continued)

    40. The SelectedValueChanged and SelectedIndexChanged Events (continued) Microsoft Visual Basic 2008: Reloaded, Third Edition 40

    41. Microsoft Visual Basic 2008: Reloaded, Third Edition 41 The Product Finder Application

    42. Microsoft Visual Basic 2008: Reloaded, Third Edition 42 The Product Finder Application (continued)

    43. Microsoft Visual Basic 2008: Reloaded, Third Edition 43 The Product Finder Application (continued)

    44. Microsoft Visual Basic 2008: Reloaded, Third Edition 44

    45. Microsoft Visual Basic 2008: Reloaded, Third Edition 45 Programming Tutorial

    46. Microsoft Visual Basic 2008: Reloaded, Third Edition 46 Programming Example

    47. Microsoft Visual Basic 2008: Reloaded, Third Edition 47 Summary The three programming structures are sequence, selection, and repetition Repetition structure (or loop): repeatedly processes a set of instructions Pretest loop tests the condition before the instructions are processed Posttest loop tests the condition after the instructions are processed

    48. Microsoft Visual Basic 2008: Reloaded, Third Edition 48 Summary (continued) Do...Loop statement: codes a pretest or posttest loop Use a While or Until condition in a Do...Loop Flowchart symbol for repetition is a diamond Counter and accumulators: variables that calculate subtotals, totals, and averages InputBox function: allows user input Verify that a variable does not contain a value of 0 before using it as a divisor

    49. Microsoft Visual Basic 2008: Reloaded, Third Edition 49 Summary (continued) List box: contains a minimum of three selections List box’s Items collection: contains the items in the list box Items.Add method: adds an item to the list Form’s Load event occurs before the form appears List box item’s index is used to access the item Items.Count property stores the number of items SelectedItem property of a list box: contains the value of the selected item in the list

    50. Microsoft Visual Basic 2008: Reloaded, Third Edition 50 Summary (continued) SelectedIndex property of a list box: contains the index position of the selected item in the list SelectedValueChanged and SelectedIndexChanged events occur when an item in a list box is selected Sleep method: delays program execution Me.Refresh: refreshes (redraws) the form Enabled property: used to enable or disable a control

More Related