Click to See Complete Forum and Search --> : Any Equivalent of "CPtrList" in VB?
deepak_warrier
October 12th, 1999, 11:27 AM
I want to make a linked-list of user Classes. Something like "CPtrList" in VC. I know that "Collections" doesn't work, because it only groups together controls under a common heading. Unlike "CPtrlist" I want to add the classes, not their addresses. Is there any Control for what I have in mind? (The classes are of the same type, but just have different data in them).
Deepak.
czimmerman
October 12th, 1999, 04:09 PM
If your class includes a data member that points to the next and/or previous object in the list, I don't understand why you can't use a collection, a dictionary, or even an array for your linked list (Since I don't know what CPtrList is, I don't know which would be the best choice). You say that a collection only groups together controls under a common heading, but I'm not sure what you mean. You can include objects of different data types within the same collection.
Charlie Zimmerman
http://www.freevbcode.com
czimmerman
October 12th, 1999, 04:16 PM
I looked at the documentation for CPtrList. You would have to implement what is known as a collection class to get all the functionality of it. This is a class that includes a collection as a member and includes custom properties and methods to extend the functionality of the collection. At least from I read, there is nothing that CPtrList does that cannot be handled by a collection or a VB class to extend the collection.
Charlie Zimmerman
http://www.freevbcode.com
deepak_warrier
October 13th, 1999, 12:55 AM
In Class1, put the code
public A as Byte
In Form1, put the code
private Sub Form_Load()
Dim X as new Class1
Dim Coll as new Collection
X.A=25
Coll.Add X
'BookMark1
X.A=6
Coll.Add X
End Sub
When I make "X.A=6", the value of the first item in the collection also becomes "6". So, at BookMark1, I added the statement "Set X=Nothing". Is that necessary, or have I made a mistake somewhere? I have the same problem whenever I pass Objects to another Object.
Deepak
czimmerman
October 13th, 1999, 01:51 PM
X is still referencing the same object, so by setting A to 6, you are setting A to 6 in the first object in the collection as well. At the bookmark, adding the statement set X = new Class1 should work for you.
Charlie Zimmerman
http://www.freevbcode.com
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.