ISM 3230 Introduction to Programming

 Chapter 7: Lists, Loops, and Printing
Chapter 7 Student Learning OBJECTIVES:

Upon completion of this chapter, you will be able to

      1. Create and use list boxes and combo boxes.
      2. Enter items into list boxes using the Properties window and the AddItem method.
      3. Determine which item in a list is selected.
      4. Use the ListCount property to determine the number of items in a list.
      5. Display a selected item from a list.
      6. Differentiate among the available types of combo boxes.
      7. Use Do/Loops and For/Next statements to iterate through a loop.
      8. Use the MsgBox function to determine the button pressed by the user.
      9. Use the string functions Left, Right, and Mid, to refer to part of a string, and use the Len function to count the number of characters in a string.
      10. Send information to the printer using the Print method.
      11. Control the format of printing using commas, semicolons, the Tab function, and the Spc function.

 

Download Example Programs

List Boxes and Combo Boxes

Filling the List

List/Combo Box Methods

cboFruits.AddItem "Kiwi"

cboFruits.AddItem cboFruits.Text

cboFruits.Clear

List/Combo Box Properties

List/Combo box Events


Do Loops

 

For/Next Loops

For loopindex = initialvalue To endvalue [Step k]

… body of loop …

Next [loopindex]


Using the MsgBox Function

 

MsgBox Values

Important button and icon values:

Examples of using instrinsic constants:

Using String Functions

 

Examine the following code to ensure yourself that it mimics the Windows activity of "zooming" to a list box entry in attempting to match what the user types:

Sending Information to the Printer

Formatting Lines

Printer.Print Tab(20); "Name:"

Printing to a Picture Box


Hands-On Programming Example


Chapter Summary:

OBJECTS

 

PROPERTIES

 

METHODS

 

STATEMENTS

 

FUNCTIONS

List box

 

List

 

AddItem

 

Do / Loop

 

Left

Combo box

 

ListCount

 

Clear

 

Exit For

 

Len

   

ListIndex

 

EndDoc

 

For / Next

 

Mid

   

Sorted

 

NewPage

     

Right

   

Style

 

Print

     

Spc

       

RemoveItem

     

Tab