Microsoft Visual Basic 2005 BASICS Lesson 11 List Boxes, For Next Loops, and Label Settings
Objectives Use the ListBox control to show multiple lines of information. Use For Next loops. Nest For Next loops. Change label font settings.
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
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
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.
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.
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.
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.
A particular slide catching your eye?
Clipping is a handy way to collect important slides you want to go back to later.