Page 268 - Excel Progamming Weekend Crash Course
P. 268

n540629 ch19.qxd  9/2/03  9:35 AM  Page 243




                  Session 19 — Creating Custom Dialog Boxes with User Forms              243

                  There are two columns on each tab. The left column lists the property name, and the
               right column displays the current property setting. To change a property, click its name.
               The way you then make changes depends on the specific property:

                   For an enumerated property (one that can take any of a set of predefined values),
                   use the drop-down list in the right column to select the value.
                   For a True/False property, double-click to toggle the value between True and False.
                   For a property with a text or numeric value, click in the right column and enter or
                   edit the property value.
                   For more complex properties, the right column displays a button with ellipses (...).
                   Click the button to display the property’s dialog box. Make changes to the settings
                   as needed; then close the dialog box to return to the properties window.


                          To get online help for a property, select the property in the Property window
                          and press F1.
                   Tip



               Form Properties
               Each user form has a set of properties that control its appearance and behavior. There are
               over 30 form properties, some of which are used infrequently. Remember that all properties
               can be set using the Properties window, and can also be read and (except for read-only
               properties) set in VBA code. The syntax for referring to properties is the same as for other
               objects:
                  UserFormName.PropertyName

                  Each user form is assigned a name when created: UserForm1, UserForm2, and so on.
               This name (the Name property) is what you use to refer to the form in VBA code. Assign
               a descriptive name to each user form as soon as you create it to avoid having to use the
               default name.
                          Generally, you set all of the user form’s properties at the design stage.
                          Setting form properties in code is usually reserved for situations where you
                  Note    need to change the appearance or behavior of the form during program
                          execution.


               Appearance Properties
               The following user form properties are related to its appearance:

                   BackColor. The color of the form background. When setting this property in the
                   Property window, select from palettes of predefined colors. In code, set this prop-
                   erty with an RGB value using the RGB function.
                   BorderColor. The color of the form border (if one is displayed). In code, set this
                   property with an RGB value.
   263   264   265   266   267   268   269   270   271   272   273