devxlogo

Make Collections Work Like Standard VB Collections

Make Collections Work Like Standard VB Collections

Add the following procedure to your collection object:

 Public Function Item(ByVal Value as Variant) _as SomeObject  Set Item = mCollection.Item(Value)  'mCollection is your private module level  'collection object.End Function

size=3>
Now, make the Item procedure default with the Procedure Attributes dialog box. Open the dialog box from the Tools menu, click the Advanced button, and set the Procedure ID to (Default). Now, instead of accessing objects in your collection like this:

   Set objSomeObject = objSomeObjects.Item(1)

size=3>
You can do this:

   Set objSomeObject = objSomeObjects(1)

size=3>

devx-admin

Share the Post: