Visual Basic Reference
Occurs when a form is loaded. For a startup form, occurs when an application starts as the result of a Load statement or as the result of a reference to an unloaded form's properties or controls.
Private Sub Form_Load( )
Private Sub MDIForm_Load( )
Typically, you use a Load event procedure to include initialization code for a form for example, code that specifies default settings for controls, indicates contents to be loaded into ComboBox or ListBox controls, and initializes form-level variables.
The Load event occurs after the Initialize event.
When you reference a property of an unloaded form in code, the form is automatically loaded but isn't automatically made visible unless the MDIChild property is set to True. If an MDIForm object isn't loaded and an MDI child form is loaded, both the MDIForm and the child form are automatically loaded and both become visible. Other forms aren't shown until you either use the Show method or set the Visible property to True.
The following code in an MDIForm Load event automatically loads an MDI child form (assuming
Form1 has its MDIChild property set to True):
Dim NewForm As New Form1 NewForm.Caption = "New Form" ' Loads form by reference.
Because all child forms become visible when loaded, the reference to the Caption property loads the form and makes it visible.
Note When you create procedures for related events, such as Activate, GotFocus, Paint, and Resize, be sure that their actions don't conflict and that they don't cause recursive events.