Can someone please explain why I am observing this action.
Lets assume today is 30 May 2015
Dim myDate as New Date
my Date is 30 May 2015
Dim TestDate as Date = myDate
TestDate is 30 May 2015
TestDate.Day = 1
TestDate is 1 May 2015 BUT so is myDate. Why?
Doesn’t myDate copy to TestDate? It’s acting like a reference. How do I prevent myDate from changing on the assignment?
What am I missing?
[quote=190837:@Michael Dosa]Can someone please explain why I am observing this action.
Lets assume today is 30 May 2015
Dim myDate as New Date
my Date is 30 May 2015
Dim TestDate as Date = myDate
TestDate is 30 May 2015
TestDate.Day = 1
TestDate is 1 May 2015 BUT so is myDate. Why?
Doesn’t myDate copy to TestDate? It’s acting like a reference. How do I prevent myDate from changing on the assignment?
What am I missing?
Thanks[/quote]
Try:
Dim TestDate As new Date
TestDate.TotalSeconds = MyDate.TotalSeconds
Now you will have two separate dates.