Load Statement

   

Loads a form or control into memory.

Syntax

Load object

The object placeholder is the name of a Form object, MDIForm object, or control array element to load.

Remarks

You don't need to use the Load statement with forms unless you want to load a form without displaying it. Any reference to a form (except in a Set or If...TypeOf statement) automatically loads it if it's not already loaded. For example, the Show method loads a form before displaying it. Once the form is loaded, its properties and controls can be altered by the application, whether or not the form is actually visible. Under some circumstances, you may want to load all your forms during initialization and display them later as they're needed.

When Visual Basic loads a Form object, it sets form properties to their initial values and then performs the Load event procedure. When an application starts, Visual Basic automatically loads and displays the application's startup form.

If you load a Form whose MDIChild property is set to True (in other words, the child form) before loading an MDIForm, the MDIForm is automatically loaded before the child form. MDI child forms cannot be hidden, and thus are immediately visible after the Form_Load event procedure ends.

The standard dialog boxes produced by Visual Basic functions such as MsgBox and InputBox do not need to be loaded, shown, or unloaded, but can simply be invoked directly.