Sample Application Info Survey

Now that you've read through the theory of creating user forms and understand the differences between various controls available in the Toolbox, you are ready for some hands-on experience. As you already know, the best way to understand a complex feature is to apply it in a real-life project. In this section, you will create a custom form for a coworker who requested that you streamline the tedious process of entering survey data into a spreadsheet.

As you work with this form (Figure 10-11), you will have the chance to experiment with many controls and their properties. Also, you will learn how to transfer data from your custom form to a worksheet (Figure 10-12).

By the end of this section, you will have the skills necessary to create a custom form to fit the unique requirements of your VBA application.

In the Project Explorer window, highlight the current project VBAProject (Chap10.xls) and change the project name in the Properties window to CustomForms.

Choose Insert | UserForm to add a blank form to your VBA project. In the Properties window, double-click the Name property and type InfoSurvey to change the default form name (UserForm1). This is the name you will use to refer to this UserForm object in your VBA procedure.

Double-click the Caption property and type the new title for the form: Info Survey. This name will appear in your form's title bar.

Double-click the BackColor property, click the Palette tab, and select a color for the form background.

Figure 10-11:

The Info Survey custom form allows the user to quickly enter data by making appropriate selections.

Figure 10-11:

The Info Survey custom form allows the user to quickly enter data by making appropriate selections.

Figure 10-12:

Each time the Info Survey form is used,the user selections are written to the worksheet.

0 -1

Post a comment