473,395 Members | 2,437 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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.

Mar 14 '07 #1
5 2449
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

39
by: Randell D. | last post by:
Folks, I'm sure this can be done legally, and not thru tricks of the trade - I hope someone can help. I'm writing a 'tool' (a function) which can be used generically in any of my projects. ...
2
by: Thomas W. Brown | last post by:
If I am using the CSharpCodeProvider to dynamically compile an in-memory assembly from some C# source, do I need to worry about signing this assembly if I'm doing the compilation, instantiation,...
4
by: DotNetJunky | last post by:
I have built a control that runs an on-line help system. Depending on the category you selected via dropdownlist, it goes out and gets the child subcategories, and if there are any, adds a new...
1
by: Andy | last post by:
Can anyone tell me if it is possible to dynamically create generic collections? simply put I want to be able to something like this : public object test(SomeBaseClass param1) { if...
9
by: Anubhav Jain | last post by:
Hi, I am having few .net source files(.cs or .vb) and I want to dynamically generate the corresponding .net project file(.csproj or .vbproj) for them without using visual studio.So that I could...
6
by: TB | last post by:
Hi All: I have this page where a rows / cells are programmatically added to to table by pushing a button. The rows contain a textbox and a associated button. What I want to is to be able to...
114
by: Jonathan Wood | last post by:
I was just wondering what naming convention most of you use for class variables. Underscore, "m_" prefix, camel case, capitalized, etc? Has one style emerged as the most popular? Thanks for...
6
by: RSH | last post by:
Hi, i have a situation where I need to dynamically create objects in a loop. My question surrounds intantiation naming in such a scenerio. Below is a snippet that is basically hardcoding each...
6
by: kelton5020 | last post by:
Hey, I am having problems adding/removing elements dynamically. I know why it's not working, I just don't know a work-around for the problem. Problem: I am dynamically creating elements, naming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.