|
-
Apr 8th, 2002, 12:15 AM
#1
Thread Starter
Frenzied Member
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.
-
Apr 8th, 2002, 05:54 PM
#2
Thread Starter
Frenzied Member
....
does this mean I'm not the only dumb one..?
Magiaus
If I helped give me some points.
-
Apr 9th, 2002, 09:09 AM
#3
Hyperactive Member
Magiaus - I'm not sure what you are asking.
In .Net you can do the following...
VB Code:
dim objUserObject as New cUserObject
Dim colX As System.Collections.ArrayList
objUserObject.Property1 = "XXX"
objUserObject.Property2 = "XXX"
colX.Add (objUserObject)
'iteration
For each objUserObject in colX
...
Next
'or
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)
-
Apr 9th, 2002, 10:46 AM
#4
Thread Starter
Frenzied Member
that's it
thanks
Magiaus
If I helped give me some points.
-
Apr 9th, 2002, 10:50 AM
#5
Thread Starter
Frenzied Member
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.
-
Apr 9th, 2002, 11:17 AM
#6
Hyperactive Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|