Alex Rivera | Logout

Can a class extend the Collection object?

Asked 2011-04-21T18:12:22.850
11

I'm trying to extend functionality of the VBA Collection object in a new class and make this class an inheritant of Collection, but the Implements Collection statement gives me the following error:

Bad interface for Implements: method has underscore in its name.

What underscore?! Add, Item, Remove, and Count are the only methods listed in the documentation for Collection. All four are underscore-free.

EDIT: To clarify, I'm making a class called UniformCollection (that only accepts members that are all of the same type, inspired by this approach). I'd like it to implement Collection, so that a UniformCollection is a Collection and can be used in place of a Collection when calling other objects' methods, etc.

I know I have to write delegating methods/properties for Add, Item, etc., and a NewEnum property for For Each to work, and I've done so already.

My problem is that the Implements Collection statement gives me the error stated above.

Bonus question: is Count a method or a property of Collection? Help calls it a property, but the Object Browser in the VBA editor calls it a function i.e. method (flying yellow box).

Edit
Report

1 Answer

3

Re RolandTumble's note on "NewEnum" :

My own experience in Access 2003 is that "For Each" works fine by importing code including the line

Attribute NewEnum.VB_UserMemId = -4

... but after I "/decompile" the file (command line switch), the line has been removed (verified on export) and the "For Each" does not function.

Unfortunately I need to use "/Decompile" when "Compress and Repair" does not fix things for me.

answered 2012-10-20T23:22:57.300

Your Answer