CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Sep 1999
    Location
    Trivandrum, Kerala, INDIA.
    Posts
    32

    Any Equivalent of "CPtrList" in VB?

    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.



  2. #2

    Re: Any Equivalent of "CPtrList" in VB?

    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


  3. #3

    Re: Any Equivalent of "CPtrList" in VB (2)

    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


  4. #4
    Join Date
    Sep 1999
    Location
    Trivandrum, Kerala, INDIA.
    Posts
    32

    Re: Any Equivalent of "CPtrList" in VB (2)

    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


  5. #5

    Re: Any Equivalent of "CPtrList" in VB (2)

    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


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

Featured