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 4 1206
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" <jo**@marymonte.com> wrote in message
news:0u********************************@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
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" <jo**@marymonte.com> wrote in message news:0u********************************@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
Hi,
I would use a with statement.
With DirectCast(slClass.Item(1), Info)
.name = "Ken"
.Priority = 1
.AppointmentDate = Now
End With
Ken
-----------------------
"J L" <jo**@marymonte.com> wrote in message
news:2d********************************@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" <jo**@marymonte.com> wrote in message news:0u********************************@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
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: Hi,
I would use a with statement.
With DirectCast(slClass.Item(1), Info) .name = "Ken" .Priority = 1 .AppointmentDate = Now End With
Ken -----------------------
"J L" <jo**@marymonte.com> wrote in message news:2d********************************@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" <jo**@marymonte.com> wrote in message news:0u********************************@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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: gerrod |
last post by:
Hi -
Does anyone know a way to created a SortedList (in the
System.Collections namespace) that will sort on VALUES instead of
KEYS... ?
The scenario is this - I have a SortedList containing...
|
by: Johannes |
last post by:
I've read that the SortedList object can sort its elements
in alphabetical or numerical order. If this is correct,
how can I set the sort order to numerical.
Regardless of the key/value pairs I...
|
by: arby |
last post by:
Hi There.
I have a SortedList collection that I add objects of a custom class
to. Rather then explain my app, my question is pretty general so....
Using a simple clsDog:
...
|
by: Prez |
last post by:
I started writing .net code yesterday and I am grasping it well enough.
I have a few questions about SortedLists.
I am using managed C++ if that makes any difference.
Of the examples I...
|
by: SHEBERT |
last post by:
Here is an example of a SortedList that works as a datasource to the ComboBox
and a generic SortedList<that does not works as a datasource to the
ComboBox.
Why? If I use List and generic List<>,...
| |
by: sck10 |
last post by:
Hello,
I have a method in my codefile that builds a sorted list (see CodeFile). I
am trying to create a class that does the same thing (see App_Code).
CodeFile...
|
by: raylopez99 |
last post by:
I seem to get name collision between the Generic collection SortedList
and C++.NET Framework collection SortedList.
How to resolve? Here are the libraries that seem to clash:...
|
by: active |
last post by:
This is where a different thread ended.
The subject of this query is quite different from that of the other thread
so I thought I should start a new thread.
I'm using
Private mItemList As...
|
by: Michael Nesslinger |
last post by:
Hello,
i am looking for an easy way to do a "RemoveAll(Predicate<Tmatch)" for
a SortedList like it is possible for a List.
My first question is:
Why is the Method not available for the...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |