Reputation: 295
I've got a list that's generated in a class file that I need to loop through to get all the entries for a specific type. I'm pulling from the correct list, but I need to get a value that is in the parent list while I'm looping through the child list inside the parent list). I am not sure of the syntax to put the parent item value with the child list item value.
This is my current code:
For Each Item In PendingList
For Each it In Item.EntryItems
strPending += "<tr><td id=""content"">" + NullToEmpty(it.Name) + "</td><td id=""testdate"">" + NullToEmpty(it.OrderDate) + "</td></tr>"
Next
Next
I am getting it.Name no problem. It's it.OrderDate that is the problem. It is not part of the EntryItems list within the Pending list. It IS however, in the Pending list. How do I get that value and display it?
Thanks
Upvotes: 1
Views: 528
Reputation: 460158
You can access the outer loop's variable from the inner loop, it's within its scope:
For Each Item In PendingList
For Each it In Item.EntryItems
' simplified '
dim itOrderDate = Item.OrderDate
Next
Next
Upvotes: 5
Reputation: 324
"Item" references the current item in PendingList, so reference that.
Note: I would change the variable name from "Item" to something more descriptive like: pendingItem.
That might clarify.
Upvotes: 2