See Also Example
Loads a form or control into memory.
The argument object is a form, MDI form, or control array element to load.
It is not necessary 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 is not already loaded. For example, the Show method loads an unloaded form before displaying it. Once the form is loaded, all properties for the form and its controls can be altered by the program, 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 are needed.
When more than one instance of a form is loaded, each form has its own set of properties and variables that can be changed independently from all other instances of the form.
When Visual Basic loads a form, it sets form properties to their initial values, then performs the Load event procedure When an application starts, Visual Basic automatically loads and displays the application's start up form..
If you load an MDI child form before loading the MDI form, the MDI form is automatically loaded before the child form is loaded. Loading an MDI child form causes it to be visible immediately after the Form_Load event ends because MDI child forms cannot be hidden.
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.
Load Statement Example
The example uses the Load statement to load a form. To try this example, paste the code into the Declarations section of a form. Then press F5 and click the form.
Sub Form_Click ()
Dim Answer, Msg ' Declare variable.
Unload Form1 ' Unload form.
Msg = "Form1 has been unloaded. Choose Yes to load and "
Msg = Msg & "display the form. Choose No to load the form "
Msg = Msg & "and leave it invisible."
Answer = MsgBox(Msg, 4) ' Get user response.
If Answer = 6 Then ' Evaluate answer.
Show ' If Yes, show form.
Load Form1 ' If No, just load it.
Msg = "Form1 is now loaded. Choose OK to display it."
MsgBox Msg ' Display message.
Show ' Show form.