Results 1 to 4 of 4

Thread: For Loop.. HELP! Arrgghh!!

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2000
    Posts
    135

    Question

    Hi..

    I have this property :

    Public Property Get NewEnum() As IUnknown
    'this property allows you to enumerate
    'this collection with the For...Each syntax
    Set NewEnum = mCol.[_NewEnum]
    End Property

    I am trying to use it to go through my collection of objects. mCol is a collection of objects. I dont have a clue what IUnknown is. This property was automatically created by VB itself. Can anyone help me in using this property in a For.. Each syntax. HELP PLEASE!!!

    Collection Class is called Products
    Single Class is called Product

    mCol has the following properties:

    mCol(Index)
    mCol.Item. -> then properties of the single class Product
    mCol.Add
    mCol.Remove
    mCol.Count

    Basically i want to Enumerate all the objects then use mCol(Index) to list them in...


    Please Help me

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Code:
    For each n in mCol
    'process item n
    next n
    where as n has to be a variant for regular datatype, except UDT's, and any object variable matching all objects in collection
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  3. #3
    Addicted Member jeroenh's Avatar
    Join Date
    Aug 2000
    Location
    Rotterdam, Holland
    Posts
    201
    You don't have to change anything to the code for it to work. You just have to go to the 'Tools' menu and select 'procedure attributes'.

    Now select the NewEnum procedure and make sure you see the details. Now set the Procedure_ID to -4. This isn't a normal option so don't use the dropdownbox. Also click on the 'Hide this member checkbox'.

    Now you enumerator is ready. You will have to retrieve Variants when using a for ech ..... next structure.
    Catch you later,

    Jeroen Hoekemeijer
    Code:
    If 1 = 2 Then MajorError

  4. #4
    Addicted Member jeroenh's Avatar
    Join Date
    Aug 2000
    Location
    Rotterdam, Holland
    Posts
    201
    I would like to know if it's possible to change the IUnkown in a known object.
    example

    Code:
    Public Property Get NewEnum As Form
          Set NewEnum = mCol.[_NewEnum] 
    End Property
    I hope that this way I do not have to pull the object with a Variant.
    Catch you later,

    Jeroen Hoekemeijer
    Code:
    If 1 = 2 Then MajorError

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width