473,657 Members | 2,453 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2455
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...@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?

Mar 14 '07 #4
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

Mar 14 '07 #5
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.

Mar 14 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

39
6521
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. When it completes, it can call a success, or a failure function. The names of these success, or failure functions will differ, and I'd like to know how I can pass the name of a function to my tool, and how my tool can call the function, using that...
2
2177
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, and invocation of a dynamic object from a strongly named assembly? If so, how do you strongly name a dynamic, in-memory assembly?
4
5476
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 dropdownlist to the screen for selection. This continues until there are no children, and then it checks for a help article list based on that last selection and displays actual articles for display. Adding the controls and getting everything...
1
1839
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 (param1.prop1 == "blah") { //logic to determine the type
9
5436
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 be able to generate and compile the project on the enviroments where Visual Studio.Net is not installed. Thanks and Regards, Anubhav Jain MTS Persistent Systems Pvt. Ltd. Ph:+91 712 2226900(Off) Extn: 2431 Mob : 094231 07471
6
1790
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 add the content of any textbox to a global variable (and a related session variable) when pushing the associate button. However whenever I push the button(s) apparently the session variable
114
7823
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 any comments. --
6
5454
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 object. My problem is that I would like to create the objects dynamically but I can't figure out how to do it How would I go about dynamically creating the required objects so that I could be using anywhere from 2 - 10 etc. ?
6
3935
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 them, and then later searching for them so I can eather append them, or delete them. Works in firefox of course. I know this isn't supposed to work, and I have no idea how to make it work. Basically when I do this: var fElement =...
0
8420
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
8516
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8617
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6176
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5642
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2743
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1970
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1733
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.