To add a UserForm to a project, do the following:
- Open the Visual Basic Editor.
- Select the command Insert | UserForm.
A new form is added to the project.

NOTE
The size of the form can be adjusted using the resize handles.
The UserForms Collection
The UserForms collection is a family of all loaded forms in the application. Like all collections, the UserForms collection has the following:
- Count – returns the number of components in the collection.
- Item – returns a specific component of the collection.
- Add – adds a new component to the collection.
Form Properties
A form has a wide range of properties that allow you to control both its appearance and its functionality.
Of course, the most frequently used properties are those that define the Name of the form and the Caption (the text displayed in the form’s title bar).
Table. Form Properties
| Property | Description |
| Name | The name of the form |
| ActiveControl | Returns a reference to the control that currently has focus |
| BackColor | Background color |
| BorderColor | Border color |
| BorderStyle | Border style. Possible values: fmBorderStyleNone, fmBorderStyleSingle |
| CanPaste | Determines whether pasting from the clipboard is allowed |
| CanRedo | Determines whether the Redo action is available |
| CanUndo | Determines whether the Undo action is available |
| Caption | Form’s title text |
| Cycle | Specifies how controls inside Frames or Pages behave when losing focus |
| DrawBuffer | Defines memory size used for redrawing images |
| Enabled | Determines whether the form is available to the user |
| ForeColor | Foreground (title text) color |
| Height, Width | Height and width of the form |
| HelpContextID | Link to a help file topic |
| InsideHeight, InsideWidth | Height and width of the user area (excluding title bar and borders) |
| KeepScrollBarsVisible | Scroll bar visibility. Possible values: fmScrollBarsNone, fmScrollBarsHorizontal, fmScrollBarsVertical, fmScrollBarsBoth |
| Left, Top | Coordinates of the form’s top-left corner |
| MouseIcon | Assigns a custom mouse pointer |
| MousePointer | Specifies mouse pointer type |
| Picture | Link to a bitmap file used as the form’s background |
| PictureAlignment | Specifies alignment of the background image |
| PictureSizeMode | Defines scaling of the background image |
| ScrollHeight, ScrollWidth | Height and width of the scrollable area |
| ScrollLeft, ScrollTop | Coordinates of the scrollable area’s top-left corner |
| SpecialEffect | Defines the form’s visual effect |
| StartUpPosition | Specifies initial position of the form |
| Tag | Custom identifier for the form |
| VerticalScrollbarSide | Defines which side scroll bars are displayed on |
| Visible | Controls whether the form is visible |
| WhatsThisButton | Displays the Help (?) button |
| Zoom | Defines zoom factor for displayed objects |
Form Methods
A form has many methods that allow you to perform a wide range of operations—from showing or hiding the form to repainting its contents.
Table. Form Methods
| Method | Description |
| Copy | Copies content to the clipboard |
| Cut | Cuts content to the clipboard |
| Hide | Hides the form without removing it from memory |
| Load | Loads the form into memory without displaying it |
| Move | Moves the form |
| Paste | Pastes content from the clipboard |
| PrintForm | Prints the form |
| RedoAction | Repeats the last Redo command |
| Repaint | Refreshes/redraws the form |
| Scroll | Scrolls the form |
| SetDefaultTabOrder | Sets the default tab order for controls |
| Show | Displays the form |
| UndoAction | Executes the last Undo command |
| Unload | Removes the form from memory |
| WhatsThisMode | Displays the Help (?) pointer |
Form Events
Event procedures allow you to control the entire lifecycle of a form—from initialization to termination.
Table. Form Events
| Event | Description |
| Activate, Deactivate | Occur when the form is activated/deactivated |
| AddControl | Occurs when a control is added |
| BeforeDragOver | Occurs during drag-and-drop |
| BeforeDropOrPaste | Occurs before drop or paste |
| Click | Occurs when the form is clicked |
| DblClick | Occurs when the form is double-clicked |
| Error | Occurs when an error is detected but cannot be passed |
| Initialize | Occurs when the form is initialized |
| Layout | Occurs when the form’s layout changes |
| KeyDown, KeyUp | Occur when any key is pressed or released while the form has focus |
| KeyPress | Occurs when any non-special key is pressed while the form has focus |
| MouseDown, MouseUp | Occur when a mouse button is pressed or released |
| MouseMove | Occurs when the mouse is moved over the form |
| QueryClose | Occurs before the form is closed |
| RemoveControl | Occurs when a control is removed |
| Resize | Occurs when the form is resized |
| Scroll | Occurs when the form is scrolled |
| Terminate | Occurs when the form is closed |
| Zoom | Occurs when the form’s zoom changes |
Displaying and Hiding Forms
When working with forms, a special role is played by one method and two operators that control the start and end of form usage:
- The Show method loads and displays the form.
- The Unload operator removes the form from the screen and memory.
- The End operator ends code execution without triggering Unload or Terminate events.
⚠️ Therefore, ending the application with End ignores cleanup code in those events.
Forms can be displayed and hidden with the Show and Hide methods.