|
-
Jul 23rd, 2009, 03:36 AM
#1
Thread Starter
Frenzied Member
[RESOLVED] Easy - Loop through collection of collections
I have a Collection, the keys are strings and the values are Collections. In the sub Collections the keys are strings and values are Singles/Floats.
How would I loop through all of the data? I need to get the keys and values not just the values.
I've tried this but it produces a cast error:
Code:
Dim de As DictionaryEntry
For Each de In MyCol
'key should be in de.Key
'value should be in de.Value
Next
Cheers
-
Jul 23rd, 2009, 03:58 AM
#2
Re: Easy - Loop through collection of collections
try this maybe:
Code:
Dim de As DictionaryEntry
de.Key = "Test"
de.Value = "1232"
For Each MyCol In de.Value
MsgBox(de.Value & " " & de.Key)
'key should be in de.Key
'value should be in de.Value
Next
* Rate It  If you Like it
__________________________________________________________________________________________
" Programming is like sex: one mistake and you’re providing support for a lifetime."
Get last SQL insert ID 
-
Jul 23rd, 2009, 04:00 AM
#3
Thread Starter
Frenzied Member
Re: Easy - Loop through collection of collections
Nevemind, solved it by using Hashtables instead of collections
-
Jul 23rd, 2009, 07:55 AM
#4
Re: [RESOLVED] Easy - Loop through collection of collections
Using a different method doesn't necessarily answer the question, however...
If it's a Dictionary, you can use a KeyValuePair Structure, Or you can loop through the keys and values (the values in this case are simply objects, but you can make them whatever you like):
Code:
Dim MyDictionary As Dictionary(Of String, Object)
For Each kvp As KeyValuePair(Of String, Object) In MyDictionary
Next
For Each key As String In MyDictionary.Keys
Next
For Each value As Object In MyDictionary.Values
Next
"Ok, my response to that is pending a Google search" - Bucky Katt.
"There are two types of people in the world: Those who can extrapolate from incomplete data sets." - Unk.
"Before you can 'think outside the box' you need to understand where the box is."
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
|