Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

A Collection of UDT arrays.

Status
Not open for further replies.

CasperTFG

Programmer
Nov 15, 2001
1,210
US
Hey all,

I have a problem with some code that I can't get around. I have 3 User Defined Types, and 8 arrays of various parts of these types. But I want to be able to save these arrays to a collection. Such as this...
[tt]

Private Type RecordItem
ID As Long
Count as Long
End Type

Private Type Record1
UID As Long
Name As String
Members() as RecordItem
End Type

Private Type Record2
UID As Long
Name As String
Groups() as Record1
End Type

Dim g_Group1() as Record1
Dim g_Group2() as Record1
Dim g_Group3() as Record1
Dim g_Group4() as Record2
Dim g_Group5() as Record3
[/tt]
So that there is how I have set up the groups as arrays of various UDT's. Now what I have to do is make a copy of these records to store the old data, then refill the records from a new structure, then move the counts from the old structure over.

So essentially what I want is something like this.
[tt]
Dim tmpGroup as Object 'or Variant or collection what ever works.
tmpGroup = g_Group1
[/tt]

The problem is that g_Group1 is an array of the type Record1, I don't want to move just one I want the whole colelction.


Craig

"I feel sorry for people who don't drink. When they wake up in the morning, that's as good as they're going to feel all day."
~Frank Sinatra
 
Instead of 3 UDTs, if you made each one a class you could add them to a collection object (or your own collection class wrapper) instead of an array.

Paul Bent
Northwind IT Systems
 

>But I want to be able to save these arrays to a collection

???

[tt]
Private Type RecordItem
ID As New Collection
Count As New Collection
End Type

...

[/tt]

Good Luck

 
Hey vb5 sorry haven't had a chance to try it out yet. I wrote it out the long way in a select statment with 8 cases, just to get past that part for now. When I get back to it to finesse it up a little I'll try it out and let you know.

Thanks

Craig

"I feel sorry for people who don't drink. When they wake up in the morning, that's as good as they're going to feel all day."
~Frank Sinatra
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top