174 Part II Programming Fundamentals
- Click the Label control in the Toolbox, and then draw a label near the top of the form to
display a title for the program. - Use the Label control to create a second label object below the first.
You’ll use this label as a title for the list box.
- Click the ListBox control in the Toolbox, and then create a list box below the second
label. - Use the Label control to draw two more labels below the list box to display program
output. - Use the Button control to create a small button on the bottom of the form.
- Open the Properties window, and then set the properties as shown in the following
table, for the objects that you have just created.
Object Property Setting
Form1 Text “Case Greeting”
Label1 Font
Name
Text
Times New Roman, Bold, 12 point
lblTitle
“International Welcome Program”
Label2 Name
Text
lblTextBoxLabel
“Choose a country”
Label3 Font
Name
Text
Microsoft Sans Serif 10 point
lblCountry
(empty)
Label4 AutoSize
BorderStyle
ForeColor
Name
Text
False
Fixed3D
Red
lblGreeting
(empty)
ListBox1 Name lstCountryBox
Button1 Name
Text
btnQuit
“Quit”
Since there are so many objects, you’ll also assign Name properties to help you easily
identify the control on the form and within your program code. (When the properties in
the Properties window are sorted alphabetically, you’ll find Name listed in parentheses
near the top of the Properties window. When the properties in the Properties window
are sorted by category, you’ll find Name listed in parentheses in the Design category .)
I recommend that you use the Name property whenever you have more than four or
five objects in a program. In this example, I’ve given the objects names that feature
a three-character prefix to identify the object type, such as btn (for button), lbl (for
label), and lst (for list box).