Jeff,
It appears that you have a collection of DateTime (Date) values. Correct?
System.DateTime is a value type, when you add a DateTime to a collection the
value will be boxed (copied to the heap) when you get the value from the
collection a copy of the boxed value will be made, when you use AddDays a
copy of the value will be made. In other words for DateTime values your code
is the way to do it, as your code is the way it works!
Reference Types (such as Control) exist on the Heap, when you add a Control
to a collection the reference will be copied to the collection, only a
single Control object will exist on the heap...
As Cor suggested. I would also recommend you look at & use the Collection
classes in System.Collecti ons & System.Collecti ons.Specialized instead of
the Micrososft.Visu alBasic.Collect ion class. As Herfried suggests the
ArrayList (from System.Collecti ons) will allow your code with casting,
because the ArrayList holds objects, your DateTime values will need to be
boxed going in (Add, Item set), and unboxed coming out (Item get, For Each)
of the ArrayList.
NOTE: In VS.NET 2005 (Whidbey) due out sometime in 2005 will support
Generics, you will be able to very easily make a strongly typed "ArrayList"
class, no boxing involved.
Hope this helps
Jay
"Jeff Stewart" <ob******@hotma il.com> wrote in message
news:46******** *************** *******@news.te ranews.com...
Let's say I create a collection of DateTime objects like so:
Dim clxn_Times As Collection = New Collection()
Let's go on to say I add 3 elements to the collection. How do I pull off
the result represented by the following?
clxn_Times(0) = clxn_Times(0).A ddDays(-1)
I can't find a way to edit an item in place. But not knowing very much
about Visual Basic (or how to phrase this problem so I can find it in the
documentation), I can't figure out how to get a "reference" to an element
so that the element can be altered in place.
--
Jeff S.