Designing the envelope and abet form

^ji&Wfa The example in this section uses a single form for either envelopes or labels. " It includes fields for name, address, city, state, and zip code. I purposely kept the form simple so that you can concentrate on technique rather than on customization. The form itself isn't all that special. It includes two command buttons — one for creating the output and another for canceling it. Each of the required fields is a text box. (You can find the source code for this example on the site at

After you create a form, you must add a little code to it to make it interact properly with the macro used to perform the actual work. The first addition is an enumeration that tells the caller which button the user clicked. Using an enumeration makes it far simpler to add features to the form later because you don't have to worry about working with actual values in your code — the enumeration makes it simpler to define the values correctly. Here's the enumeration used with this example (simply right-click the form and choose View Code from the context menu to add the enumeration):

' A list of

click values.

Public Enum




End Enum

You also need to define a public variable to hold the button press state. The example uses a value named Result of type DialogResult. Now it's time to add event handlers. The easy way to perform this task is to double-click the buttons on the front of your form. Here's all you need for the event handler code:

The event handler sets Result to the correct value (Create for the Create button and Cancel for the Cancel button). It then calls Me.Hide to hide the form from view.

Was this article helpful?

0 0

Post a comment