You are running into one of the limitations of Implements in VBA. You can't implement another class if the other class has any public methods or properties with an underscore in the name Collection class of course has NewEnum but any underscore will cause a problem For example, if you created a class AddressClass that had the following: Public Address_City As String Then created another class CustomerAddress : Implements AddressClass Private Property Get ClassInterface_Address_City() As String End Property Private Property Let ClassInterface_Address_City(ByVal RHS As String) End Property When you compile, you will get an error "Object module needs to implement 'Address_City' for interface 'AddressClass'. " Changing the property to AddressCity makes the error go away Possible solution: If I understand correctly, you want to implement the collection class so you can pass your new class to methods that take in collections as parameters.Is it possible to alter those methods?
My suggestion would be to create your own collection class MyCollection and then implement it instead. I. E UniformMyCollection That way you can completely avoid problems with underscores As for Count I would trust the Object Browser over the help text anytime.
On the other hand, if you are creating your own collection class, it doesn't matter which one you choose.
You are running into one of the limitations of Implements in VBA. You can't implement another class if the other class has any public methods or properties with an underscore in the name. Collection class of course has _NewEnum but any underscore will cause a problem.
For example, if you created a class AddressClass that had the following: Public Address_City As String Then created another class CustomerAddress: Implements AddressClass Private Property Get ClassInterface_Address_City() As String End Property Private Property Let ClassInterface_Address_City(ByVal RHS As String) End Property When you compile, you will get an error "Object module needs to implement 'Address_City' for interface 'AddressClass'. " Changing the property to AddressCity makes the error go away. Possible solution: If I understand correctly, you want to implement the collection class so you can pass your new class to methods that take in collections as parameters.Is it possible to alter those methods?
My suggestion would be to create your own collection class MyCollection and then implement it instead. I.e. UniformMyCollection That way you can completely avoid problems with underscores.
As for Count, I would trust the Object Browser over the help text anytime. On the other hand, if you are creating your own collection class, it doesn't matter which one you choose.
1 Good explanation. So the bottom line is, if I understand correctly, that the answer to my question (title) is no? – Jean-François Corbett 6 hours ago.
VBA has a lot of limitations on what classes you can implement. The NewEnum is tripping up Collection, but even if it wasn't, there could very well be something else in that class to trip it up. I think it reports the first problem it finds.
Because Collection has so few properties and methods, I just rewrite them. Private mcolParts As Collection Public Sub Add(clsPart As CPart) mcolParts. Add clsPart, CStr(clsPart.
PartID) End Sub Public Property Get Count() As Long Count = mcolParts. Count End Property Public Property Get Item(vItm As Variant) As CPart Set Item = mcolParts. Item(vItm) End Property Public Sub Remove(vIndex As Variant) mcolParts.
Remove vIndex End Sub In don't know why the OB shows methods (they look like green boxes to me). For my money, methods either change multiple properties or interact with something outside of the class. Everything else is a property.
I'd call both Count and Index properties.
Thanks, but I've already done all this stuff... see clarifying edit. – Jean-François Corbett May 2 at 18:22.
Dick Kusleika has most of it, but if you want to use For Each on your custom class, you'll also need: '--- required additional property that allow to enumerate the collection with For Each Public Property Get NewEnum() As IUnknown Set NewEnum = m_ColParts. _NewEnum End Property This isn't discussed in either of the links I found in my Favorites (this one or this one), but they're both worth reading. If I find the site that talks about NewEnum I'll do an Edit to add it.
EDIT Neither of these links are the one I was looking for, either, but both discuss the NewEnum property (including a little extra voodoo that neeeds to be added): Here and here. Both of these talk about Excel, but the VBA is the same in other Office applications (including the need for the export->text edit->import process to get "Attributes").
Not sure I quite understand your problem, but you could use Dictionary (Microsoft Scripting Runtime library) instead. I usually prefer it over Collection, just because it's more versatile and faster.
Not a real answer. – Jean-François Corbett May 2 at 18:21 I see what you are trying to do now. Can't help you much though.
I haven't done that. Professional Excel Development talks about how to go about doing that kind of thing and can probably correct anything you might be doing wrong, or it might just on be possible. Good luck!
– Jon49 May 2 at 19:54.
You are running into one of the limitations of Implements in VBA. You can't implement another class if the other class has any public methods or properties with an underscore in the name. Collection class of course has _NewEnum but any underscore will cause a problem.
When you compile, you will get an error "Object module needs to implement 'Address_City' for interface 'AddressClass'." Changing the property to AddressCity makes the error go away. Possible solution: If I understand correctly, you want to implement the collection class so you can pass your new class to methods that take in collections as parameters.
Is it possible to alter those methods? My suggestion would be to create your own collection class MyCollection and then implement it instead. UniformMyCollection That way you can completely avoid problems with underscores.
As for Count, I would trust the Object Browser over the help text anytime. On the other hand, if you are creating your own collection class, it doesn't matter which one you choose.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.