Home All Groups Group Topic Archive Search About

Array Objects pointers, value types reference types??

Author
10 Feb 2006 12:15 AM
plau011
Hi all,
I thought I understood .Net Framework with value types and
referencetypes but apparently not.
So I have this code. Excuse me if it's not 100% correct I cut and paste
and shortened it a bit to make things clearer
So basically the purpose of this code was to have to arrays passed in
byref _BInfo
and CInfo.
Then base on another list of items that gets passed through is to fill
one or the other.
I was wanting to use a array of objects pointer to "point" to BInfo or
CInfo Array

'Dim BInfo(,) As Object  'passed in byref
'Dim CInfo(,) As Object 'passed in byref
' Dim Mycoll as collection
Dim NodetoSet(,) As Object
Dim UpperBound As Integer

          For Each X in Coll Loop ' Not important
               If X.UseB Then
                 ReDim BINFO(30, UBound(BInfo) + 1)
                  NodetoSet = BINFO  ' What is this doing. Is it
copying data from BINFO to NodetoSet why? Shouldn't it treat as a
pointer??
                Else
                   ReDim CInfo(30, UBound(CInfo) + 1)
                    NodetoSet = CInfo  ' What is this doing. Is it
copying data from BINFO to     NodetoSet why? Shouldn't it treat as a
pointer??
                 End If
                 UpperBound = UBound(NodetoSet, 2) - 1
                 'doing stuff with NodeToSet
                 NodeToSet(UpperBound,1) = "hello"
                 NodeToSet(UpperBound,1) = "goodbye"  'And so on....
            Next
Thanks in advance

Author
10 Feb 2006 12:32 AM
Chris
plau***@hotmail.com wrote:
Show quoteHide quote
> Hi all,
> I thought I understood .Net Framework with value types and
> referencetypes but apparently not.
> So I have this code. Excuse me if it's not 100% correct I cut and paste
> and shortened it a bit to make things clearer
> So basically the purpose of this code was to have to arrays passed in
> byref _BInfo
> and CInfo.
> Then base on another list of items that gets passed through is to fill
> one or the other.
> I was wanting to use a array of objects pointer to "point" to BInfo or
> CInfo Array
>
> 'Dim BInfo(,) As Object  'passed in byref
> 'Dim CInfo(,) As Object 'passed in byref
> ' Dim Mycoll as collection
> Dim NodetoSet(,) As Object
> Dim UpperBound As Integer
>
>           For Each X in Coll Loop ' Not important
>                If X.UseB Then
>                  ReDim BINFO(30, UBound(BInfo) + 1)
>                   NodetoSet = BINFO  ' What is this doing. Is it
> copying data from BINFO to NodetoSet why? Shouldn't it treat as a
> pointer??
>                 Else
>                    ReDim CInfo(30, UBound(CInfo) + 1)
>                     NodetoSet = CInfo  ' What is this doing. Is it
> copying data from BINFO to     NodetoSet why? Shouldn't it treat as a
> pointer??
>                  End If
>                  UpperBound = UBound(NodetoSet, 2) - 1
>                  'doing stuff with NodeToSet
>                  NodeToSet(UpperBound,1) = "hello"
>                  NodeToSet(UpperBound,1) = "goodbye"  'And so on....
>             Next
> Thanks in advance
>

Ok, I can't say I fully understand what you are doing here, but I think
I see some issue that may help you.

1. 'Dim BInfo(,) As Object  'passed in byref
Objects will always be passed by reference. Only native data types are
able to be passed by value.

2. NodetoSet = BINFO
This is setting NodetoSet to the same as Binfo.  They both point to the
same data object now.

Hope this helps.
Chris