[AccessD] Iterator functionality

John W Colby jwcolby at gmail.com
Wed Oct 2 11:23:46 CDT 2013


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