Microsoft Visual Basic 2005 BASICS - PowerPoint PPT Presentation

1 / 17
About This Presentation
Title:

Microsoft Visual Basic 2005 BASICS

Description:

Control the font, style, and size. Using the Font property of the label control ... The Step keyword can also be used to make a For Next loop count backward. ... – PowerPoint PPT presentation

Number of Views:63
Avg rating:3.0/5.0
Slides: 18
Provided by: bcsSo
Category:

less

Transcript and Presenter's Notes

Title: Microsoft Visual Basic 2005 BASICS


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

2
Objectives
  • Use the ListBox control to show multiple lines of
    information.
  • Use For Next loops.
  • Nest For Next loops.
  • Change label font settings.

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

4
Using the ListBox Control (cont.)
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

6
Using For Next Loops (cont.)
7
Using the Step Keyword to Count Forward
  • Step keyword
  • Used to cause the loop counter to count by an
    increment other than one

8
Using the Step Keyword to Count Backward
  • Use a negative value
  • After the Step keyword to count backward

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

10
Nesting For Next Loops (cont.)
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.

12
Changing Label Font Settings (cont.)
13
Changing Label Font Settings (cont.)
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.

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.

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.

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.
Write a Comment
User Comments (0)
About PowerShow.com