[AccessD] Iterator functionality

Gustav Brock Gustav at cactus.dk
Wed Oct 2 12:13:50 CDT 2013


Hi John

I've never heard of IUnknown in relation to VBA.
Thanks!

/gustav


>>> jwcolby at gmail.com 02-10-13 18:23 >>>
I learned something new the other day. You can place a hidden method in a class (export to file, make the change, import back in to the FE) which creates a single iterator for a single collection.

'

'*******************************************************************************

'Code for collection iterator

'Export to a text file and examine for special properties

'vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv

'

Public Sub Add(ByVal cOpenArg As clsOpenArg, Optional ByVal key As Variant)

     If IsMissing(key) Then

         mcolOpenArg cTDFConn

     Else

         mcolOpenArg cTDFConn, key

     End If

End Sub

Public Function Count() As Long

     Count = mcolTDFConn.Count

End Function

Public Function Item(ByVal Index As Variant) As clsOpenArg

     Set Item = mcolTDFConn(Index)

End Function

Public Sub Remove(ByVal Index As Variant)

     mcolTDFConn.Remove Index

End Sub

Public Function NewEnum() As IUnknown

     Set NewEnum = mcolTDFConn.[_NewEnum]

End Function

'

'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

'Code for collection iterator

'Export to a text file and examine for special properties

'*******************************************************************************

'


Suddenly you can do things like

dim cOpenArg as clsOpenArg

     for each cOpenArg in cOpenArgs
     next cOpenArg

It is the NewEnum function which allows the class to do this.

Obviously you have to modify this code to deal with whatever is in your collection.


John W. Colby

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



More information about the AccessD mailing list