PC Review Forums Newsgroups Microsoft DotNet Microsoft VB .NET Dynamically creating and naming collections

Reply

Dynamically creating and naming collections

 
Thread Tools Rate Thread
Old 14-03-2007, 10:46 AM   #1
paulb
Guest
 
Posts: n/a
Default 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.

  Reply With Quote
Old 14-03-2007, 11:05 AM   #2
Mike Hofer
Guest
 
Posts: n/a
Default Re: Dynamically creating and naming collections

On Mar 14, 6:46 am, "paulb" <paulberming...@gmail.com> wrote:
> 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?

  Reply With Quote
Old 14-03-2007, 01:51 PM   #3
Brian Gideon
Guest
 
Posts: n/a
Default Re: Dynamically creating and naming collections

On Mar 14, 5:46 am, "paulb" <paulberming...@gmail.com> wrote:
> 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

  Reply With Quote
Old 14-03-2007, 02:25 PM   #4
paulb
Guest
 
Posts: n/a
Default Re: Dynamically creating and naming collections

On Mar 14, 2:51 pm, "Brian Gideon" <briangid...@yahoo.com> wrote:
> On Mar 14, 5:46 am, "paulb" <paulberming...@gmail.com> wrote:
>
> > 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?

  Reply With Quote
Old 14-03-2007, 02:42 PM   #5
Brian Gideon
Guest
 
Posts: n/a
Default Re: Dynamically creating and naming collections

On Mar 14, 9:25 am, "paulb" <paulberming...@gmail.com> wrote:
> On Mar 14, 2:51 pm, "Brian Gideon" <briangid...@yahoo.com> wrote:
>
>
>
>
>
> > On Mar 14, 5:46 am, "paulb" <paulberming...@gmail.com> wrote:

>
> > > 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

  Reply With Quote
Old 14-03-2007, 03:53 PM   #6
paulb
Guest
 
Posts: n/a
Default Re: Dynamically creating and naming collections

On Mar 14, 3:42 pm, "Brian Gideon" <briangid...@yahoo.com> wrote:
> On Mar 14, 9:25 am, "paulb" <paulberming...@gmail.com> wrote:
>
>
>
> > On Mar 14, 2:51 pm, "Brian Gideon" <briangid...@yahoo.com> wrote:

>
> > > On Mar 14, 5:46 am, "paulb" <paulberming...@gmail.com> wrote:

>
> > > > 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.

  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off