PC Review


Reply
Thread Tools Rate Thread

Array of Collections

 
 
Dreiding
Guest
Posts: n/a
 
      7th Dec 2008
I'm trying to creat an array of collection without success.

I have a Class called "MyClass"
In the control module I use the following commands:
Dim myCollections() as Collection

Redim myCollections(7) 'assume I have 7 collections to populate

As I loop through the data rows, I populate the class "MyClass"
and them based on the content of a field(0-6), add it to the appropriate
collection(i).

'here's how I add the class to the collection
Call myCollection(i).add(Item:=myClass)

For the first data row (i=0), the myCollection(0).item(1) is correct

My problen is when the second data row is read with a different index (i=1)
I end up with myCollection(0).item(1) being updated as myCollection(1).add is
executed.

Why would myCollection(0) be changed when I add to myCollection(1)?

Thanks,
- Pat




 
Reply With Quote
 
 
 
 
IanKR
Guest
Posts: n/a
 
      7th Dec 2008
> I'm trying to creat an array of collection without success.
>
> I have a Class called "MyClass"
> In the control module I use the following commands:
> Dim myCollections() as Collection
>
> Redim myCollections(7) 'assume I have 7 collections to populate


Redim myCollections(1 to 7)

>
> As I loop through the data rows, I populate the class "MyClass"
> and them based on the content of a field(0-6), add it to the appropriate
> collection(i).
>
> 'here's how I add the class to the collection
> Call myCollection(i).add(Item:=myClass)
>
> For the first data row (i=0), the myCollection(0).item(1) is correct
>
> My problen is when the second data row is read with a different index
> (i=1)
> I end up with myCollection(0).item(1) being updated as myCollection(1).add
> is
> executed.
>
> Why would myCollection(0) be changed when I add to myCollection(1)?


Watch for typos - is it myCollection or myCollections?

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
2 String collections to two-dimensional array Zaur Bahramov Microsoft C# .NET 1 23rd Sep 2009 04:28 PM
Convert 'System.Collections.ObjectModel.ReadOnlyCollection(Of String)' to '1-dimensional array of String'. roidy Microsoft VB .NET 12 17th Jul 2009 10:53 AM
A List of Collections and Custom Collections ExcelMonkey Microsoft Excel Programming 1 20th Dec 2007 10:04 PM
How to Declare an array of collections? Hiram Microsoft VB .NET 1 24th Mar 2004 09:37 PM
Array versus Collections Matt Microsoft C# .NET 1 4th Jan 2004 02:06 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:31 PM.