By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,827 Members | 2,177 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,827 IT Pros & Developers. It's quick & easy.

Dynamically creating and naming collections

P: n/a
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.

Mar 14 '07 #1
Share this Question
Share on Google+
5 Replies


P: n/a
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?

Mar 14 '07 #2

P: n/a
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

Mar 14 '07 #3

P: n/a
On Mar 14, 2:51 pm, "Brian Gideon" <briangid...@yahoo.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 CreateCollection method I can use?

Mar 14 '07 #4

P: n/a
On Mar 14, 9:25 am, "paulb" <paulberming...@gmail.comwrote:
On Mar 14, 2:51 pm, "Brian Gideon" <briangid...@yahoo.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 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

Mar 14 '07 #5

P: n/a
On Mar 14, 3:42 pm, "Brian Gideon" <briangid...@yahoo.comwrote:
On Mar 14, 9:25 am, "paulb" <paulberming...@gmail.comwrote:
On Mar 14, 2:51 pm, "Brian Gideon" <briangid...@yahoo.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 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
This is what I was looking for.

Thanks,

Paul.

Mar 14 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.