Adding Forms

Adding Forms

Until now we have used only one form per application.

However, as your programs become more complex it may be necessary for you to use more than one form.

Each new form is considered an object and maintains its own objects, properties, and event procedures.

 

Adding Forms

The first form in a program is named Form1, and subsequent forms are named Form2, form3, etc.

Additional forms can serve a variety of purposed but are commonly used to display additional messages to users.

 

Blank or Predesigned Forms

You can create a new form by clicking on the Add Form command on the Project menu.

A dialog box appears, prompting you for the type of form you want to create.

You can choose a standard form type or create your own from a blank form.

 

How Forms Are Used

In VB you have a good amount of control over forms.

You can load or unload them, hide or unhide them at will.

To load a form we use the Load formname statement. (Ex. Load Form2)

To them show the form we use the formname.Show mode

 

Form Statements

Formename is the name of the form and mode is 0 for a nonmodal form, or one that a user can switch away from, or 1 for a modal form, one that requires the user to take action. (Ex. Form2.Show 0)

Hiding and Unloading Forms

You can hide forms by using the Hide method, and you can unload forms by using the Unload statement.

These keywords are opposites of Show and Load.

Ex. Form2.Hide and Unload Form2

 

The Italian Program

Try to modify the Italian program to use an additional form to view the translation instead of a message box.

You need to use the Load form and the Hide methods.