Dynamically creating and naming collections

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • paulb

    Dynamically creating and naming collections

    Hey,

    Does anyone know how to create and name collections dynamically? I am
    writing some vb.net (VB2005) code which requires me to create an
    unknown number
    of collections and then add them to a master collection so I can
    operate on them in a loop.

    Thanks,

    Paul.

  • Mike Hofer

    #2
    Re: Dynamically creating and naming collections

    On Mar 14, 6:46 am, "paulb" <paulberming... @gmail.comwrote :
    Hey,
    >
    Does anyone know how to create and name collections dynamically? I am
    writing some vb.net (VB2005) code which requires me to create an
    unknown number
    of collections and then add them to a master collection so I can
    operate on them in a loop.
    >
    Thanks,
    >
    Paul.
    Right off hand, it sounds like you want an XML DOM. But without more
    information, it's hard to say. What, exactly, are you trying to do?
    Can you provide a little more information?

    Comment

    • Brian Gideon

      #3
      Re: Dynamically creating and naming collections

      On Mar 14, 5:46 am, "paulb" <paulberming... @gmail.comwrote :
      Hey,
      >
      Does anyone know how to create and name collections dynamically? I am
      writing some vb.net (VB2005) code which requires me to create an
      unknown number
      of collections and then add them to a master collection so I can
      operate on them in a loop.
      >
      Thanks,
      >
      Paul.
      Paul,

      What about using a Dictionary to store each individual collection?
      The key in the Dictionary would be the name and the value would be the
      actual collection.

      Brian

      Comment

      • paulb

        #4
        Re: Dynamically creating and naming collections

        On Mar 14, 2:51 pm, "Brian Gideon" <briangid...@ya hoo.comwrote:
        On Mar 14, 5:46 am, "paulb" <paulberming... @gmail.comwrote :
        >
        Hey,
        >
        Does anyone know how to create and name collections dynamically? I am
        writing some vb.net (VB2005) code which requires me to create an
        unknown number
        of collections and then add them to a master collection so I can
        operate on them in a loop.
        >
        Thanks,
        >
        Paul.
        >
        Paul,
        >
        What about using a Dictionary to store each individual collection?
        The key in the Dictionary would be the name and the value would be the
        actual collection.
        >
        Brian
        How do I create a new collection in the code? The answer is probably
        simple.

        Currently I am using:

        Private Sub Form_Load
        Dim Collection1 As Collection

        Collection1 = New Collection

        Collection1.Add (Class1, Key1)

        End SubI would like to be able to create new collections when an event
        is triggered. Is there some kind of CreateCollectio n method I can use?

        Comment

        • Brian Gideon

          #5
          Re: Dynamically creating and naming collections

          On Mar 14, 9:25 am, "paulb" <paulberming... @gmail.comwrote :
          On Mar 14, 2:51 pm, "Brian Gideon" <briangid...@ya hoo.comwrote:
          >
          >
          >
          >
          >
          On Mar 14, 5:46 am, "paulb" <paulberming... @gmail.comwrote :
          >
          Hey,
          >
          Does anyone know how to create and name collections dynamically? I am
          writing some vb.net (VB2005) code which requires me to create an
          unknown number
          of collections and then add them to a master collection so I can
          operate on them in a loop.
          >
          Thanks,
          >
          Paul.
          >
          Paul,
          >
          What about using a Dictionary to store each individual collection?
          The key in the Dictionary would be the name and the value would be the
          actual collection.
          >
          Brian
          >
          How do I create a new collection in the code? The answer is probably
          simple.
          >
          Currently I am using:
          >
          Private Sub Form_Load
          Dim Collection1 As Collection
          >
          Collection1 = New Collection
          >
          Collection1.Add (Class1, Key1)
          >
          End SubI would like to be able to create new collections when an event
          is triggered. Is there some kind of CreateCollectio n method I can use?-
          Hi,

          The following example creates 10 new List collections and adds them to
          a Dictionary. The List collections are keyed by a String
          representation of the numbers 1 through 10.

          Private m_Dictionary as New Dictionary(Of String, List(Of SomeObject))

          Public Sub Foo()

          For i as Integer = 0 To 10
          m_Dictionary.Ad d(i.ToString(), New List(Of SomeObject))
          Next

          End Sub

          Brian

          Comment

          • paulb

            #6
            Re: Dynamically creating and naming collections

            On Mar 14, 3:42 pm, "Brian Gideon" <briangid...@ya hoo.comwrote:
            On Mar 14, 9:25 am, "paulb" <paulberming... @gmail.comwrote :
            >
            >
            >
            On Mar 14, 2:51 pm, "Brian Gideon" <briangid...@ya hoo.comwrote:
            >
            On Mar 14, 5:46 am, "paulb" <paulberming... @gmail.comwrote :
            >
            Hey,
            >
            Does anyone know how to create and name collections dynamically? I am
            writing some vb.net (VB2005) code which requires me to create an
            unknown number
            of collections and then add them to a master collection so I can
            operate on them in a loop.
            >
            Thanks,
            >
            Paul.
            >
            Paul,
            >
            What about using a Dictionary to store each individual collection?
            The key in the Dictionary would be the name and the value would be the
            actual collection.
            >
            Brian
            >
            How do I create a new collection in the code? The answer is probably
            simple.
            >
            Currently I am using:
            >
            Private Sub Form_Load
            Dim Collection1 As Collection
            >
            Collection1 = New Collection
            >
            Collection1.Add (Class1, Key1)
            >
            End SubI would like to be able to create new collections when an event
            is triggered. Is there some kind of CreateCollectio n method I can use?-
            >
            Hi,
            >
            The following example creates 10 new List collections and adds them to
            a Dictionary. The List collections are keyed by a String
            representation of the numbers 1 through 10.
            >
            Private m_Dictionary as New Dictionary(Of String, List(Of SomeObject))
            >
            Public Sub Foo()
            >
            For i as Integer = 0 To 10
            m_Dictionary.Ad d(i.ToString(), New List(Of SomeObject))
            Next
            >
            End Sub
            >
            Brian
            This is what I was looking for.

            Thanks,

            Paul.

            Comment

            Working...