Results 1 to 2 of 2

Thread: Its not possible to add an UDT to a Collection?

  1. #1

    Thread Starter
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    Its not possible to add an UDT to a Collection?

    I have a program where I declared a Private Type, then I created an Array of UDTs.

    The problem is I can't use ParamArray, its not posible with Arrays of UDT.
    I need to pas the array to a Function, I don't want to create another function to do exactly the same, its too much code.

    Then I tryied to use a Collection, so I could pass the collection as parameter, but, it seems its not possible to add UDTs to a collection.

    This doesn't work:
    VB Code:
    1. Private Type myType
    2.     ala As Integer
    3.     ele As String
    4. End Type
    5.  
    6. Private mCol As Collection
    7.  
    8. Private Sub Form_Load()
    9. Dim p As myType
    10.  
    11.     Set mCol = New Collection
    12.     mCol.Add p 'Error here
    13. End Sub
    I need to put these UDTs inside something, and pass that something to a Function, How could I do that?
    I know Objects work well with Collections, but I'm trying to avoid converting this UDT to a CLASS.

  2. #2
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385

    Re: Its not possible to add an UDT to a Collection?

    You can create a data definition class and add that.

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