Microsoft Office Tutorials and References
In Depth Information
Property routines may also have one or more parameters. Typically, you would use parame
ters with a property routine if you wanted to simulate an array. For example the following
code fragment declares a private class-level variable named MyNames , which is an array of
100 Strings . The code fragment also includes two property routines that make the property
appear as an array.
Private MyNames (99) As String
Public Property Get NameArray(index As Long) As String
NameArray = MyNames(index)
Public Property Let NameArray (index As Long, value as String)
MyNames = value
Note You can specify as many parameters as you wish for the property routines.
However, they must be identical between the Get and Let Set routines, except for the very last /
parameter in the Let Set routine, which contains the value for the property. /
Someone using the class might access the property like this:
MyObject.NameArray (10) = “Item 10 in the array”
Or like this:
MyVar = MyObject.NameArray (10)
Tip Property Routines and Parameters
Although you can specify a list of parameters for a property routine, you should limit the use
of the parameters in a property routine to those parameters that make the property routine
look like an array. If you need to use parameters other than subscripts, you should consider
creating one or more methods with the parameters you need.