[AccessD] Iterator, take 3

John W Colby jwcolby at gmail.com
Wed Oct 2 12:18:06 CDT 2013


Google is my friend!  ;)

http://p2p.wrox.com/excel-vba/25214-newenum-function.html
http://www.vb-helper.com/howto_sorted_collection.html

Seriously though apparently the collection object has this "spare" method just waiting for us to 
hook it.  The NewEnum is apparently just a delegate that is sitting there waiting.  We hook it and 
off we go.

I ran across it one day with a REALLY good explanation.  I lost the book mark.  Sigh.

In the end that is really all you need though.  It only works for a single collection of course but 
OOP tells us that a class is about one thing anyway.

As you can see, the other functions (add, remove etc) are just wrapping the same methods of the 
collection.

actually though, when you edit it you have to do the following: (notice the "attribute" line)

Public Function NewEnum() As IUnknown
  attribute enum.vb_usermemId = -4
  Set NewEnum = mcolOpenArg.[_NewEnum]
End Function

That attribute ends up there but hidden when you pull it back in.

I may actually get this right yet.

John W. Colby

Reality is what refuses to go away
when you do not believe in it

On 10/2/2013 12:47 PM, Charlotte Foust wrote:
> So where did you find the IUnknown object type?
>
> Charlotte
>
>
> On Wed, Oct 2, 2013 at 9:37 AM, John W Colby <jwcolby at gmail.com> wrote:
>
>> Boy did I hose that last one up.  Sorry about that.  This is what the
>> iterator code would look like for my clsOpenArg.
>>
>> '
>> '***************************************************************
>> ********************
>> 'Code for collection iterator
>> 'Export to a text file and examine for special properties
>> '**vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv**vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv**
>> vvvvvvvvvvvvvvvvvvv
>> '
>> Public Sub Add(ByVal cOpenArg As clsOpenArg, Optional ByVal key As Variant)
>>      If IsMissing(key) Then
>>          mcolOpenArg.Add cTDFConn
>>      Else
>>          mcolOpenArg.Add cTDFConn, key
>>      End If
>> End Sub
>> Public Function Count() As Long
>>      Count = mcolOpenArg.Count
>> End Function
>> Public Function Item(ByVal Index As Variant) As clsOpenArg
>>      Set Item = mcolOpenArg(Index)
>> End Function
>> Public Sub Remove(ByVal Index As Variant)
>>      mcolOpenArg.Remove Index
>> End Sub
>> Public Function NewEnum() As IUnknown
>>      Set NewEnum = mcolOpenArg.[_NewEnum]
>> End Function
>> '
>> '^^^^^^^^^^^^^^^^^^^^^^^^^^^^^**^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^**
>> ^^^^^^^^^^^^^^^^^^^^
>> 'Code for collection iterator
>> 'Export to a text file and examine for special properties
>> '***************************************************************
>> ********************
>>
>> --
>> John W. Colby
>>
>> Reality is what refuses to go away
>> when you do not believe in it
>>
>> --
>> AccessD mailing list
>> AccessD at databaseadvisors.com
>> http://databaseadvisors.com/**mailman/listinfo/accessd<http://databaseadvisors.com/mailman/listinfo/accessd>
>> Website: http://www.databaseadvisors.**com<http://www.databaseadvisors.com>
>>



More information about the AccessD mailing list