|
-
Sep 16th, 2009, 01:23 PM
#1
Thread Starter
Fanatic Member
Is there a way to create a collection of collections?
Is there a way to create a collection of collections?
e.g. I created a collection ListOf(Lines)
After I add all my lines to it, I want to store this colleciton in another listOf(Collections). The reason I want to do this is because i want to create several separate collections of lines and I'll need to loop through them all to look for a certain line and I thought this would be a good approach if it's possible.
i tried to create a listOf(Collection) but when i try to add my listOf(Lines) to it, it complains because the list is a colleciton of lines.
thanks,
Proctor
-
Sep 16th, 2009, 01:35 PM
#2
Re: Is there a way to create a collection of collections?
List(Of List(Of Lines))
-tg
-
Sep 16th, 2009, 02:32 PM
#3
Thread Starter
Fanatic Member
Re: Is there a way to create a collection of collections?
A list of a list ....that's brilliant!!! I gave it a try and it works great!
thank you for your help!!
may i ask another quick question?
i want to build my collections of lines on the fly. e.g. the first i will be called colList1 and will be hard-coded like this:
dim colList1 as new listOf(lines)
then, when i need to start a new list of lines i wanted to do something like this in my code:
dim colList & "2" as new listOf(lines)
i haven't had any luck with this. do you also know if this is possible?
thanks again for showing me how to do a list of a list.....
Proctor
-
Sep 16th, 2009, 03:08 PM
#4
Re: Is there a way to create a collection of collections?
nope... you can't do it like that... once you put your list in a list, you can assign a new list to your same variable... just make sure it is a a NEW list.
-tg
-
Sep 16th, 2009, 03:08 PM
#5
Fanatic Member
Re: Is there a way to create a collection of collections?
If you are adding a new list of lines to your collection then you would do this:
Code:
lst.Add(New List(of Lines))
There is no naming of items within your collection. You would have to use the Find function to find a match to whatever you are searching for or use iteration to go through each element and/or subelement (since your nesting collections).
Edit: unless you have a custom class that has a name property, then you can put your text, concatenated and all as its name!
If you are looking to declare a variable on the fly for use in code, I do not think that is not gonna happen. You cannot concatenate strings to create a variable name either. (ie Dim str & i as String where i is part of a For loop) You can however create controls or classes using the CType and/or DirectCast functions on the fly and name them as you please.
Hope that helps a little bit....
D
Platforms of choice: Visual Studio 2005/2008 Professional : Visual Studio 2010 Enterprise : PHP - Notepad++/WAMP
Please Rate If I helped you. 
Please remember to mark threads as closed if your issue has been resolved.
Reserved Words in Access | Connection Strings
-
Sep 16th, 2009, 03:13 PM
#6
Re: Is there a way to create a collection of collections?
 Originally Posted by dminder
If you are adding a new list of lines to your collection then you would do this:
Code:
lst.Add(New List(of Lines))
There is no naming of items within your collection. You would have to use the Find function to find a match to whatever you are searching for or use iteration to go through each element and/or subelement (since your nesting collections).
Edit: unless you have a custom class that has a name property, then you can put your text, concatenated and all as its name!
If you are looking to declare a variable on the fly for use in code, I do not think that is not gonna happen. You cannot concatenate strings to create a variable name either. (ie Dim str & i as String where i is part of a For loop) You can however create controls or classes using the CType and/or DirectCast functions on the fly and name them as you please.
Hope that helps a little bit....
D
There's also the Dictionary(Of String, List(Of Lines)) .... then you can give any string name as the key to each of your lists...
-tg
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|