Using Public Variables

As described earlier, when you create properties for your custom objects, you can also create properties for existing objects using public variables. To do so, just add the public variable declaration to the class module of the existing object, such as an existing class for a form. Again, this is not the recommended way to create properties. As discussed previously, I do not recommend this approach for three primary reasons. First, you cannot manipulate the value because the property is set; second, you cannot create read-only and write-only properties; third, you cannot easily validate what is assigned to public variables. A better way to create properties, discussed next, does not have these drawbacks.

0 0

Post a comment