Load and Unload Forms

AutoCAD ActiveX

 
Load and Unload Forms
 
 
 

There may be times when you want to load a form into memory during runtime, but not show the form. You may choose to do this to better control when the load time occurs in your application, or when you need programmatic access to the form but do not want to display the form to the user.

To load a form, but not display it, use the VBA Load method. The Show method can then be used to make the form visible at the appropriate time in your application's execution. Remember, the user can't interact with your form until it is visible.

If the Show method is called and the form has not been loaded, it will be loaded automatically.

There may also be times when you will want to unload a form specifically. Unloading a form removes that form from memory and all the memory associated with the form is reclaimed. Until the form is loaded again by using either the Load or Show method, a user can't interact with the form, and the form can't be manipulated programmatically. You may choose to unload a form when you know the form will not be used again in the application and you want to reclaim the memory.

The Hide method does not perform an unload. If your application ends and a form has not been unloaded, it will be unloaded automatically. The following table compares the VBA Show, Hide, Load, and Unload methods:

VBA Show, Hide, Load, and Unload methods

Method

Use

Show

Displays a form. If the form has not been loaded, it is loaded automatically.

Hide

Hides a form. The form is not unloaded from memory.

Load

Loads a form into memory but does not display it.

Unload

Unloads a form from memory. This can be done explicitly from the Unload method, or automatically at the termination of the application.