Home All Groups Group Topic Archive Search About
Author
27 Jun 2005 8:32 PM
J L
I have a sortedlist (ConflictList) that contains a string identifier
(ShipmentNumber) for the key and a structure (AppointmentInfo) for the
value. The structure memebers are strings, dates and intgers (i.e. no
objects).

I pass this sorted list by reference to a function. And do the
following type of loop

dim i as integer
for i = 0 to ConflictList.count - 1
   dim apt as AppointmentInfo = _
      Ctype(ConflictList.GetByIndex(i), AppointmentInfo)

< Here is my questions:
After some processing I want to change the value of one of the
memebers of the original sorted list...can I do it by simply assigning
the new value to the variable I declared above?>

apt.Door = theNewDoor

<at this point is the original sorted list changed?>

next

I hope my question makes sense. I get totally confused with the
reference/value/scope issues. Like a mind twister for me :>)

TIA
John

Author
27 Jun 2005 9:23 PM
Ken Tucker [MVP]
Hi,

        Instead of using a structure use a class.  You will be able to
change values in the sorted list if they contain a class.  You will not be
able to change the value in a structure.

   Public Class Info
        Public name As String
        Public AppointmentDate As DateTime
        Public Priority As Integer
    End Class




        Dim slClass As SortedList


        slClass = New SortedList
        Dim clsAi As New Info
        With clsAi
            .name = "Ken"
            .Priority = 1
            .AppointmentDate = Now
        End With

        slClass.Add(1, clsAi)

        DirectCast(slClass.Item(1), Info).name = "New Name"

        Trace.WriteLine(DirectCast(slClass.Item(1), Info).name)


Ken
-----------------
"J L" <j***@marymonte.com> wrote in message
news:0un0c15tim3ifm6ciutd9dbi33b7pil9pi@4ax.com...
I have a sortedlist (ConflictList) that contains a string identifier
(ShipmentNumber) for the key and a structure (AppointmentInfo) for the
value. The structure memebers are strings, dates and intgers (i.e. no
objects).

I pass this sorted list by reference to a function. And do the
following type of loop

dim i as integer
for i = 0 to ConflictList.count - 1
   dim apt as AppointmentInfo = _
      Ctype(ConflictList.GetByIndex(i), AppointmentInfo)

< Here is my questions:
After some processing I want to change the value of one of the
memebers of the original sorted list...can I do it by simply assigning
the new value to the variable I declared above?>

apt.Door = theNewDoor

<at this point is the original sorted list changed?>

next

I hope my question makes sense. I get totally confused with the
reference/value/scope issues. Like a mind twister for me :>)

TIA
John
Author
27 Jun 2005 10:31 PM
J L
Thanks Ken,
I am trying that now. Can I create a variable that references the
original class to keep from having so many DirectCast statements in my
code?

i.e.

dim apt as Info = DirectCast(slClass.Item(1), Info)

and now use apt.name = "New Name"
etc. and have this updating the original class?

Thanks again,
John

On Mon, 27 Jun 2005 17:23:24 -0400, "Ken Tucker [MVP]"
<vb***@bellsouth.net> wrote:

Show quoteHide quote
>Hi,
>
>        Instead of using a structure use a class.  You will be able to
>change values in the sorted list if they contain a class.  You will not be
>able to change the value in a structure.
>
>   Public Class Info
>        Public name As String
>        Public AppointmentDate As DateTime
>        Public Priority As Integer
>    End Class
>
>
>
>
>        Dim slClass As SortedList
>
>
>        slClass = New SortedList
>        Dim clsAi As New Info
>        With clsAi
>            .name = "Ken"
>            .Priority = 1
>            .AppointmentDate = Now
>        End With
>
>        slClass.Add(1, clsAi)
>
>        DirectCast(slClass.Item(1), Info).name = "New Name"
>
>        Trace.WriteLine(DirectCast(slClass.Item(1), Info).name)
>
>
>Ken
>-----------------
>"J L" <j***@marymonte.com> wrote in message
>news:0un0c15tim3ifm6ciutd9dbi33b7pil9pi@4ax.com...
>I have a sortedlist (ConflictList) that contains a string identifier
>(ShipmentNumber) for the key and a structure (AppointmentInfo) for the
>value. The structure memebers are strings, dates and intgers (i.e. no
>objects).
>
>I pass this sorted list by reference to a function. And do the
>following type of loop
>
>dim i as integer
>for i = 0 to ConflictList.count - 1
>   dim apt as AppointmentInfo = _
>      Ctype(ConflictList.GetByIndex(i), AppointmentInfo)
>
>< Here is my questions:
>After some processing I want to change the value of one of the
>memebers of the original sorted list...can I do it by simply assigning
>the new value to the variable I declared above?>
>
>apt.Door = theNewDoor
>
><at this point is the original sorted list changed?>
>
>next
>
>I hope my question makes sense. I get totally confused with the
>reference/value/scope issues. Like a mind twister for me :>)
>
>TIA
>John
>
Author
27 Jun 2005 11:35 PM
Ken Tucker [MVP]
Hi,

        I would use a with statement.

With DirectCast(slClass.Item(1), Info)
            .name = "Ken"
            .Priority = 1
            .AppointmentDate = Now
End With

Ken
-----------------------

"J L" <j***@marymonte.com> wrote in message
news:2dv0c1d0d7ocdnrsa9id6akh6v8s6op0vh@4ax.com...
Thanks Ken,
I am trying that now. Can I create a variable that references the
original class to keep from having so many DirectCast statements in my
code?

i.e.

dim apt as Info = DirectCast(slClass.Item(1), Info)

and now use apt.name = "New Name"
etc. and have this updating the original class?

Thanks again,
John

On Mon, 27 Jun 2005 17:23:24 -0400, "Ken Tucker [MVP]"
<vb***@bellsouth.net> wrote:

Show quoteHide quote
>Hi,
>
>        Instead of using a structure use a class.  You will be able to
>change values in the sorted list if they contain a class.  You will not be
>able to change the value in a structure.
>
>   Public Class Info
>        Public name As String
>        Public AppointmentDate As DateTime
>        Public Priority As Integer
>    End Class
>
>
>
>
>        Dim slClass As SortedList
>
>
>        slClass = New SortedList
>        Dim clsAi As New Info
>        With clsAi
>            .name = "Ken"
>            .Priority = 1
>            .AppointmentDate = Now
>        End With
>
>        slClass.Add(1, clsAi)
>
>        DirectCast(slClass.Item(1), Info).name = "New Name"
>
>        Trace.WriteLine(DirectCast(slClass.Item(1), Info).name)
>
>
>Ken
>-----------------
>"J L" <j***@marymonte.com> wrote in message
>news:0un0c15tim3ifm6ciutd9dbi33b7pil9pi@4ax.com...
>I have a sortedlist (ConflictList) that contains a string identifier
>(ShipmentNumber) for the key and a structure (AppointmentInfo) for the
>value. The structure memebers are strings, dates and intgers (i.e. no
>objects).
>
>I pass this sorted list by reference to a function. And do the
>following type of loop
>
>dim i as integer
>for i = 0 to ConflictList.count - 1
>   dim apt as AppointmentInfo = _
>      Ctype(ConflictList.GetByIndex(i), AppointmentInfo)
>
>< Here is my questions:
>After some processing I want to change the value of one of the
>memebers of the original sorted list...can I do it by simply assigning
>the new value to the variable I declared above?>
>
>apt.Door = theNewDoor
>
><at this point is the original sorted list changed?>
>
>next
>
>I hope my question makes sense. I get totally confused with the
>reference/value/scope issues. Like a mind twister for me :>)
>
>TIA
>John
>
Author
28 Jun 2005 12:03 AM
J L
Great Ken. Thank you for all your help!!

John

On Mon, 27 Jun 2005 19:35:31 -0400, "Ken Tucker [MVP]"
<vb***@bellsouth.net> wrote:

Show quoteHide quote
>Hi,
>
>        I would use a with statement.
>
>With DirectCast(slClass.Item(1), Info)
>            .name = "Ken"
>            .Priority = 1
>            .AppointmentDate = Now
>End With
>
>Ken
>-----------------------
>
>"J L" <j***@marymonte.com> wrote in message
>news:2dv0c1d0d7ocdnrsa9id6akh6v8s6op0vh@4ax.com...
>Thanks Ken,
>I am trying that now. Can I create a variable that references the
>original class to keep from having so many DirectCast statements in my
>code?
>
>i.e.
>
>dim apt as Info = DirectCast(slClass.Item(1), Info)
>
>and now use apt.name = "New Name"
>etc. and have this updating the original class?
>
>Thanks again,
>John
>
>On Mon, 27 Jun 2005 17:23:24 -0400, "Ken Tucker [MVP]"
><vb***@bellsouth.net> wrote:
>
>>Hi,
>>
>>        Instead of using a structure use a class.  You will be able to
>>change values in the sorted list if they contain a class.  You will not be
>>able to change the value in a structure.
>>
>>   Public Class Info
>>        Public name As String
>>        Public AppointmentDate As DateTime
>>        Public Priority As Integer
>>    End Class
>>
>>
>>
>>
>>        Dim slClass As SortedList
>>
>>
>>        slClass = New SortedList
>>        Dim clsAi As New Info
>>        With clsAi
>>            .name = "Ken"
>>            .Priority = 1
>>            .AppointmentDate = Now
>>        End With
>>
>>        slClass.Add(1, clsAi)
>>
>>        DirectCast(slClass.Item(1), Info).name = "New Name"
>>
>>        Trace.WriteLine(DirectCast(slClass.Item(1), Info).name)
>>
>>
>>Ken
>>-----------------
>>"J L" <j***@marymonte.com> wrote in message
>>news:0un0c15tim3ifm6ciutd9dbi33b7pil9pi@4ax.com...
>>I have a sortedlist (ConflictList) that contains a string identifier
>>(ShipmentNumber) for the key and a structure (AppointmentInfo) for the
>>value. The structure memebers are strings, dates and intgers (i.e. no
>>objects).
>>
>>I pass this sorted list by reference to a function. And do the
>>following type of loop
>>
>>dim i as integer
>>for i = 0 to ConflictList.count - 1
>>   dim apt as AppointmentInfo = _
>>      Ctype(ConflictList.GetByIndex(i), AppointmentInfo)
>>
>>< Here is my questions:
>>After some processing I want to change the value of one of the
>>memebers of the original sorted list...can I do it by simply assigning
>>the new value to the variable I declared above?>
>>
>>apt.Door = theNewDoor
>>
>><at this point is the original sorted list changed?>
>>
>>next
>>
>>I hope my question makes sense. I get totally confused with the
>>reference/value/scope issues. Like a mind twister for me :>)
>>
>>TIA
>>John
>>
>