Displaying, Using, and Hiding User Forms

Once you have designed a User Form, how exactly do you go about displaying it, accessing its controls, and so on? You'll see the specifics in the demonstration to be presented later, but it will be helpful to outline the steps first:

1.
Create an instance of the User Form:
Dim TheForm As New MyUserForm
2.
If necessary, set initial values for form controls and properties:
TheForm.txtName.Value = "Enter name here"
3.
Display the form using its Show method:
TheForm.Show
4.
The user will now work with the form, entering data, and so on.
5.
Close the form by executing its Hide method. This is usually done in the form code, in the event procedure for a Command Button:
 Private Sub cmdOK_Click() Hide End Sub ...

Get Office® XP Development with VBA now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.