ppt lesson 11

17
Microsoft Visual Basic 2005 BASICS Lesson 11 List Boxes, For Next Loops, and Label Settings

Upload: linda-bodrie

Post on 17-May-2015

991 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Ppt lesson 11

Microsoft Visual Basic 2005 BASICS

Lesson 11

List Boxes, For Next Loops, and Label Settings

Page 2: Ppt lesson 11

Microsoft Visual Basic 2005 BASICS 2

Objectives

Use the ListBox control to show multiple lines of information.

Use For Next loops. Nest For Next loops. Change label font settings.

Page 3: Ppt lesson 11

Microsoft Visual Basic 2005 BASICS 3

Using the ListBox Control

ListBox control Enables you to display a list of items to the

user Add information to a ListBox

Use the Items.Add method Remove all items added to a ListBox

Use the Items.Clear method

Page 4: Ppt lesson 11

Microsoft Visual Basic 2005 BASICS 4

Using the ListBox Control (cont.)

Page 5: Ppt lesson 11

Microsoft Visual Basic 2005 BASICS 5

Using For Next Loops

For Next loop Specifically designed for repeating a block

of code a specific number of times Always begins with a For statement and

ends with a Next statement Always involves a Counter variable

Page 6: Ppt lesson 11

Microsoft Visual Basic 2005 BASICS 6

Using For Next Loops (cont.)

Page 7: Ppt lesson 11

Microsoft Visual Basic 2005 BASICS 7

Using the Step Keyword to Count Forward

Step keyword Used to cause the loop counter to count by

an increment other than one

Page 8: Ppt lesson 11

Microsoft Visual Basic 2005 BASICS 8

Using the Step Keyword to Count Backward

Use a negative value After the Step keyword to count backward

Page 9: Ppt lesson 11

Microsoft Visual Basic 2005 BASICS 9

Nesting For Next Loops

For Next loops can be nested Within other For Next loops or within Do loops

When you nest For Next loops Each nested loop must be completely

contained within the outer loop

Page 10: Ppt lesson 11

Microsoft Visual Basic 2005 BASICS 10

Nesting For Next Loops (cont.)

Page 11: Ppt lesson 11

Microsoft Visual Basic 2005 BASICS 11

Changing Label Font Settings

Control the font, style, and size Using the Font property of the label control

You can make labels appear in any font installed on your computer.

Page 12: Ppt lesson 11

Microsoft Visual Basic 2005 BASICS 12

Changing Label Font Settings (cont.)

Page 13: Ppt lesson 11

Microsoft Visual Basic 2005 BASICS 13

Changing Label Font Settings (cont.)

Page 14: Ppt lesson 11

Microsoft Visual Basic 2005 BASICS 14

Summary

Visual Basic 2005 includes a ListBox control for displaying lists of information. The Items.Add method adds items to a ListBox control. The Items.Clear method removes all entries in a ListBox control.

A For Next loop is specifically designed for repeating a block of code a specific number of times.

Page 15: Ppt lesson 11

Microsoft Visual Basic 2005 BASICS 15

Summary (cont.)

A For Next loop always begins with a For statement and ends with a Next statement. The statements between the For and Next statements are repeated the number of times specified in the For Next loop.

For Next loops always involve a Counter variable.

Page 16: Ppt lesson 11

Microsoft Visual Basic 2005 BASICS 16

Summary (cont.)

If you want a For Next loop to count by an increment other than 1, you can use the Step keyword. The Step keyword can also be used to make a For Next loop count backward.

For Next loops can be nested.

Page 17: Ppt lesson 11

Microsoft Visual Basic 2005 BASICS 17

Summary (cont.)

Indenting your code can help make nested For Next loops easier to read. You can also use Next statements that specify the counter variable of the loop.

You can use the Font property to change the font, style, and size of a label.