Chapter 14 Managing Windows Forms and Controls at Run Time 357
feature lists the forms available in the Forms collection, as shown in the following
screen shot:
Note that you can also open and manipulate forms directly by using the following
syntax:
HelpInfo.ShowDialog()
This statement opens the HelpInfo .vb form as a dialog box by using the ShowDialog
method.
Alternatively, you can use the Show method to open the form, but in that case, Visual
Basic won’t consider HelpInfo .vb to be a dialog box; the form is a non-modal form that
the user can switch away from and return to as needed. In addition, the DialogResult
property in the HelpInfo .vb form’s Button1_Click event procedure won’t close the
HelpInfo .vb form. Instead, the program statement Me.Close is required.
Tip Keep the differences between modal and non-modal forms in mind as you build your
own projects. There are differences between each type of form, and you’ll find that each
style provides a benefit to the user.
Now you’ll run the program to see how a multiple-form application works.
Run the program
- Click the Start Debugging button on the Standard toolbar.
The first form, LuckySeven .vb, in the Lucky Seven project appears.
- Click the Spin button seven or eight times to play the game.
Your screen looks similar to this: