Adding controls

Oddly enough, the VBE doesn't have menu commands that let you add controls to a dialog box. You must use the Toolbox, which I describe in Chapter 16

to add controls. Normally, the Toolbox pops up automatically when you activate a UserForm in the VBE. If it doesn't, you can display the Toolbox by choosing ViewOToolbox.

Follow along to add a control to the UserForm:

1. Click the Toolbox tool that corresponds to the control you want to add.

2. Click in the UserForm.

3. Drag the control into position.

Alternatively, you can simply drag a control from the Toolbox to the UserForm to create a control with the default dimensions. Figure 17-1 shows a UserForm that contains a few controls.

Figure 17-1:

A UserForm with a few controls added.

Figure 17-1:

A UserForm with a few controls added.

A UserForm may contain vertical and horizontal grid lines, which help align the controls you add. When you add or move a control, it snaps to the grid. If you don't like this feature, you can turn off the grids:

1. Choose ToolsOOptions in the VBE.

2. In the Options dialog box, select the General tab.

3. Set your desired options in the Form Grid Settings section.

0 0

Post a comment