Adagio
Well-known member
- Joined
- Dec 12, 2005
- Messages
- 162
- Programming Experience
- Beginner
I have a sub with this:
public sub DoSomething()
Dim dte As Date = someDate
dte.AddSeconds(5)
If dte < Date.Now Then
' doSomeCode
End If
end sub
someDate is set when some other sub is called ( someDate = date.now )
What I want to happen is that the code inside the if tag in DoSomething() should only be used when at least 5 seconds has passed since the other sub was called
Using the above code gives me two problems. First the AddSeconds(5) sub doesn't add 5 seconds to it's value. After calling AddSeconds the dte.Seconds is the same as someDate.Seconds... why? I would have guessed that calling AddSeconds(5) would add 5 seconds to it's value...
Then there's the problem with the IF date < date part. The first time DoSomething() is called is when dte is the exact same as date.now... but why does it still execute the code inside the if tag if they are the same?
public sub DoSomething()
Dim dte As Date = someDate
dte.AddSeconds(5)
If dte < Date.Now Then
' doSomeCode
End If
end sub
someDate is set when some other sub is called ( someDate = date.now )
What I want to happen is that the code inside the if tag in DoSomething() should only be used when at least 5 seconds has passed since the other sub was called
Using the above code gives me two problems. First the AddSeconds(5) sub doesn't add 5 seconds to it's value. After calling AddSeconds the dte.Seconds is the same as someDate.Seconds... why? I would have guessed that calling AddSeconds(5) would add 5 seconds to it's value...
Then there's the problem with the IF date < date part. The first time DoSomething() is called is when dte is the exact same as date.now... but why does it still execute the code inside the if tag if they are the same?