DateTime and Pointers

I’m having this issue:

lets suppose:

dim vDates() as NotesDateTime

then in a loop, i complete the dates, and vDates(1) = 9/9/99

Dim date As New NotesDateTime(“”)

Set date = vDates(1)

after doing:

date.AdjustMonth(1)

date is then 9/10/99, and so does vDates(1)!!!

Obviously i don’t want vDates(1) to change, only date.

This sounds like a pointers issue, but i can not completely understand it.

But it looks like when i do Set date = vDates(1), i’m pointing date to vDates(1), and if i change one, so does the other?

Thanks.

Subject: DateTime and Pointers

When you assign one object variable to another, they both refer to the SAME object. If you need an independent object, you need to create a new object.

Subject: RE: DateTime and Pointers

Well, you are saying what i already suspected, but i need a solution :wink:

Actually, when i do:

Set date = vDates(1)

I want date to get the value of vDates(1).

But i tried set date.LsLocaltime = vDates(1).LsLocaltime, and it did not worked.

Subject: RE: DateTime and Pointers

Set date = New NotesDateTime(vDates(1).LsLocalTime)

Subject: RE: DateTime and Pointers

Thanks. That is what i was testing, now, wouldn’t that generate a New NotesDateTime each time it is called?

Subject: RE: DateTime and Pointers

A new object, yes, but that’s what you want – the old one will be garbage collected when the next new one is created.