Appending Classes

Hello All,

I have a class array (clsConnections) that consists of 5 Integer properties, and One Class (which has other Integer Properties) and no Methods other than a constructor.

Dim Connections(-1) As clsConnections
Prop1 As Integer
Prop2 As Integer
Prop3 As Integer
Prop4 As Integer
Prop5 As Integer
ConnectionDetails As clsConnectionDetials

I use this code to append the class, but am not sure how to append the Class Array
Cons As New clsConnections
Cons.Prop1 = 1
etc etc etc

ConnectionDetails.Append Cons

Now, I want to change the ConnectionDetails to an array also. So that the Connections class will hold multiple ConnectionDetails for each Element of its array:
Prop1 As Integer
Prop2 As Integer
Prop3 As Integer
Prop4 As Integer
Prop5 As Integer
ConnectionDetails(-1) As clsConnectionDetials

My question is, how to append the properties of the Connection Class, and then ONLY to append the Properties of the ConnectionDetails that belong TO the element of the Connection class to which the Connection Details apply?

Also, while writing this, it occurred to me that maybe just using a database might be easier?!

Thoughts?

Thank you,
Tim

Try something like

ConnectionDetails(-1) As clsConnectionDetials

dim Cons As New clsConnections
Cons.Prop1 = 1
etc etc etc

dim Detail as new clsConnectionDetails
Detail.Append Cons

ConnectionDetails.Append Detail

Thanks Tim!

Will try that.
Tim

As an addon to the original question, how are the elements in the second array accessed?
I tried this code but it did not work(compile).


n = Cons(i).ConnectionDetails(d).Ubound

I believe the part the Compiler is complaining of, is the .Ubound. But how to know how many elements exist?

TIm

I’m a little fuzzy about what in your code is an actual array. Especially this part:

[quote=26738:@Tim Seyfarth]ConnectionDetails As clsConnectionDetials

I use this code to append the class, but am not sure how to append the Class Array
Cons As New clsConnections
Cons.Prop1 = 1
etc etc etc

ConnectionDetails.Append Cons
[/quote]
Here, you’re calling ConnectionDetails.Append, but ConnectionDetails is not an array. I mimicked that in my code:

But, again, Detail is not an array. It’s a clsConnectionDetails object.

Can you provide a little more detail to clarify?