Hiding a Custom Dialog Box

To remove a dialog box from the screen, either you can wait for the user to click a button whose DismissButton property is True, or you can create an event procedure for a control, as shown in the following example.


Sub HideDialog()
    If MsgBox("Remove dialog box?", vbYesNo) = vbYes Then
        ActiveDialog.Hide
    End If
End Sub

When the user clicks the control this procedure is attached to, a message is displayed asking whether the dialog box should be removed. If the user answers yes, the dialog box is removed. If the CancelButton property for the control is True, the Show method returns False. Otherwise, the Show method returns True.