Dynamically creating and naming collections

  • Thread starter Thread starter paulb
  • Start date Start date
P

paulb

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.
 
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?
 
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
 
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 CreateCollection method I can use?
 
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 CreateCollection 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.Add(i.ToString(), New List(Of SomeObject))
Next

End Sub

Brian
 
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.Add(i.ToString(), New List(Of SomeObject))
Next

End Sub

Brian

This is what I was looking for.

Thanks,

Paul.
 
Back
Top