I constructed a small test to validate what actually
happens. The structure used looks like this:
Public Structure SomeData
Dim MyName As String
Dim MyChildren() As String
Dim ID As Int16
End Structure
And then I declared 2 other variables:
Dim MyData as SomeData
Dim YourData() as SomeData
ReDim YourData(5)
ReDim MyData.MyChildren(2)
MyData.MyName = "John"
MyData.MyChildren(0) = "Andy"
MyData.MyChildren(1) = "Sally"
MyData.ID = 1
YourData(0) = MyData
YourData(0).MyName = "David"
MyData.ID = 2
YourData(0).ID = 3
YourData(0).MyChildren(0) = "George"
MyData.MyChildren(1) = "Jane"
The result was that MyData.MyChildren(0) = "George" and
YourData().MyChildren(0) = "George" but MyData.MyName
= "John" and YourData(0).MyName = "David". So it looks
like it only copies pointers for those inner arrays and
not strings even though strings are listed as "reference"
types.
[quoted text, click to view] >-----Original Message-----
>Darrell Wesley wrote:
>
>> So the question is which of these statements is correct
>> when it comes to assigning one structure to another of
the
>> same type as in YourSystem = MySystem.
>
>The first statement is correct, the second one is slighly
>misleading. A structure holds its data under its own
memory
>allocation, but its data may contain a pointer (reference)
>which points to data outside its own memory allocation.
>
>Or, to put in another way: When you assign one struct to
>another, all values (and pointers) are copied, but not the
>objects which are pointed to.
>
>
>.