Results 1 to 6 of 6

Thread: Collections [resolved]

  1. #1

    Thread Starter
    Frenzied Member Magiaus's Avatar
    Join Date
    Mar 2002
    Location
    swamp land
    Posts
    1,267

    Arrow Collections [resolved]

    Ok I fell kinda dumb asking this but here goes.

    back in vb 6 to make a collection of objects I would just
    Code:
    Dim cObjs As Collection
    
    cObjs.Add(mObj)
    now I looked at Implementing ICollection and a Hashtable and a Storedlist and well it makes since but I don't ( I feel slow because I bet it works the same) see any example of throwing an object into the collection just use numbers or what not...

    here is why I feel dumb by the way I wrote this reusable collection class about 2 months ago when I was making some COM object or another and wll I thought I had collections down pat....

    it doesn't support remove but i didn't need remove

    it's for implementing stuff like
    Code:
    class.objs(1).doSomething
    class.objs(1).objs.doSomething
    Code:
    Option Explicit
    Private mObjs As New Collection
    
    Friend Function Add(ByRef obj As Variant, Optional iName As String = "Internal Name")
        Dim sName As String
        If iName = "Internal Name" Then
            sName = mObjs.Count + 1
        Else
            sName = iName
        End If
        mObjs.Add obj, sName
    End Function
    
    Public Function NewEnum() As IUnknown
       Set NewEnum = mObjs.[_NewEnum]
    End Function
    
    Public Property Get Count() As Integer
        Count = mObjs.Count
    End Property
    
    Public Property Get Child(ByVal Index As Variant) As Variant
        Set Child = mObjs(Index)
    End Property
    so anyway i feel dumb please explain it to me....
    Last edited by Magiaus; Apr 9th, 2002 at 10:50 AM.
    Magiaus

    If I helped give me some points.

  2. #2

    Thread Starter
    Frenzied Member Magiaus's Avatar
    Join Date
    Mar 2002
    Location
    swamp land
    Posts
    1,267

    ....

    does this mean I'm not the only dumb one..?
    Magiaus

    If I helped give me some points.

  3. #3
    Hyperactive Member Bananafish's Avatar
    Join Date
    Jan 2001
    Posts
    394
    Magiaus - I'm not sure what you are asking.

    In .Net you can do the following...

    VB Code:
    1. dim objUserObject as New cUserObject
    2.       Dim colX As System.Collections.ArrayList
    3.  
    4.       objUserObject.Property1 = "XXX"
    5.       objUserObject.Property2 = "XXX"
    6.       colX.Add (objUserObject)
    7.  
    8. 'iteration
    9.  
    10.  
    11.       For each objUserObject in colX
    12. ...
    13.       Next
    14.  
    15. 'or
    16.  
    17.      objUserObject  = CType(colX.Item(0), cUserObject)


    Naturally instead of an ArrayList you could use bitArray, stack, queue (and others - can't remember them off hand but they are all collections that function in slightly different ways. The arraylist is the one most similar to the vb6 collection)

  4. #4

    Thread Starter
    Frenzied Member Magiaus's Avatar
    Join Date
    Mar 2002
    Location
    swamp land
    Posts
    1,267

    that's it

    thanks
    Magiaus

    If I helped give me some points.

  5. #5

    Thread Starter
    Frenzied Member Magiaus's Avatar
    Join Date
    Mar 2002
    Location
    swamp land
    Posts
    1,267

    i'll explain agian too

    what i was asking basicly was how to make a collection of objects in vb.net and i said i felt dumb asking about something as simple as collections and tried to explain why i felt dumb

    thanks
    Magiaus

    If I helped give me some points.

  6. #6
    Hyperactive Member Bananafish's Avatar
    Join Date
    Jan 2001
    Posts
    394
    I think .Net makes us all feel dumb sometimes.

    It can be very frustrating knowing how to do something so well in vb6 - and then trying to do it the .net way...

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