Show Method

Applies To

CodePane object, UserForm object.

Description

Displays a UserForm object.

Syntax

[object.]Show

The optional object is an object expression that evaluates to an object in the Applies To list. If object is omitted, the UserForm associated with the active UserForm module is assumed to be object.

Remarks

If the specified object isn't loaded when the Show method is invoked, Visual Basic automatically loads it.

A UserForm is always modal; therefore, the user must respond before using any other part of the application. No subsequent code is executed until the UserForm is hidden or unloaded.

Although other forms in the application are disabled when a UserForm is displayed, other applications are not.

See Also

Hide method, Load statement, Unload statement.

Example

The following example assumes two UserForms in a program. In UserForm1's Initialize event, UserForm2 is loaded and shown. When the user clicks UserForm2, it is hidden and UserForm1 appears. When UserForm1 is clicked, UserForm2 is shown again.

' This is the Initialize event procedure for UserForm1.
Private Sub UserForm_Initialize()
    Load UserForm2
    UserForm2.Show
End Sub
' This is the Click event for UserForm2.
Private Sub UserForm_Click()
    UserForm2.Hide
End Sub

' This is the click event for UserForm1.
Private Sub UserForm_Click()
    UserForm2.Show
End Sub
Example (Extensibility Object Model)

The following example uses the Show method to move the specified code pane to the foreground.

Application.VBE.CodePanes(2).Show