140 Part II Programming Fundamentals
The ListBox1_SelectedIndexChanged event procedure processes the selections you make
in the list box and looks like this:
The heart of the event procedure is a Select Case decision structure. In the next chapter,
we’ll discuss how this group of program statements selects one choice from many.
For now, notice how each section of the Select Case block assigns a sample value to
one of the fundamental data type variables and then assigns the variable to the Text
property of the Label4 object on the form. I used code like this in Chapter 3 to process
list box choices, and you can use these techniques to work with list boxes and data
types in your own programs.
Note If you have more than one form in your project, you need to declare variables in
a slightly different way (and place) to give them scope throughout your program (that is, in
each form that your project contains). The type of variable that you’ll declare is a public, or
global, variable, and it’s declared in a module, a special file that contains declarations and
procedures not associated with a particular form. For information about creating public
variables in modules, see Chapter 10, “Creating Modules and Procedures .”
- Scroll through the ListBox1_SelectedIndexChanged event procedure, and examine each
of the variable assignments closely.
Try changing the data in a few of the variable assignment statements and running the
program again to see what the data looks like. In particular, you might try assigning