
Signature
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
> > Why this?
> >
[quoted text clipped - 4 lines]
>
> And that's the output on my box.
:(((((
> Could you post a short but complete program which demonstrates the
> problem?
This is not simple, because the code is inside a buiness object used in a
3-tiers web-based application.
This is the property:
Public Property RegistrationDateTime() As DateTime
Get
Return _registrationDateTime
End Get
Set(ByVal Value As DateTime)
If Value = Nothing Then Throw New
ArgumentNullException("RegistrationDateTime")
If Value < New DateTime(2005, 1, 1) Then Throw New
ArgumentOutOfRangeException("registrationDateTime must be after gen, 1 2005")
If Value > New DateTime(2025, 1, 1) Then Throw New
ArgumentOutOfRangeException("registrationDateTime must be before gen, 1 2025")
_registrationDateTime = Value
Me.MarkAsModified()
End Set
End Property
Because value is #1/15/2004# I've an error on the second test. If I execute
on command window the code I previously posted, I've the wrong output. It
seems I've some very very strange problem with datetime behavior..
thanks
PIEBALD - 26 Jan 2005 16:05 GMT
Only problem I see is that when I tried it with C#, the compiler told me that
I can't compare the DateTime value with null (nothing).
If yours compiles, then I don't know.
Trapulo - 26 Jan 2005 18:19 GMT
In VB I can (if I use = and not "IS" of course)
> Only problem I see is that when I tried it with C#, the compiler told me that
> I can't compare the DateTime value with null (nothing).
>
> If yours compiles, then I don't know.
Jon Skeet [C# MVP] - 26 Jan 2005 17:11 GMT
> > Could you post a short but complete program which demonstrates the
> > problem?
>
> This is not simple, because the code is inside a buiness object used in a
> 3-tiers web-based application.
So take the code out of the business object, and try to show the
problem in a console app.
I can't see anything in your code which would stop it from being part
of a simple console app...
<snip>
> Because value is #1/15/2004# I've an error on the second test. If I execute
> on command window the code I previously posted, I've the wrong output. It
> seems I've some very very strange problem with datetime behavior..
I'd avoid using the command window for this kind of thing - try to
reproduce it in a standalone way which doesn't involve the debugger.

Signature
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Trapulo - 26 Jan 2005 18:23 GMT
Oh my GOD!
I solved, and you are right.
The problem was a stupid error with data value. The error was raised by the
FIRST test, but the VS debugger reported the yellow-background line on the
second. So I was thinking the problem was on the second, but was on the
first test.
Anyway, the command window has this strange and wrong behavior. It reports a
bad value with my quick-test command, so I think there is some bug. At
runtime is all ok.
Thanks!
> > Because value is #1/15/2004# I've an error on the second test. If I execute
> > on command window the code I previously posted, I've the wrong output. It
> > seems I've some very very strange problem with datetime behavior..
>
> I'd avoid using the command window for this kind of thing - try to
> reproduce it in a standalone way which doesn't involve the debugger.
Jay B. Harlow [MVP - Outlook] - 27 Jan 2005 22:37 GMT
Trapulo,
In addition to the other comments.
>> > >? new DateTime(2005, 1, 1).tostring
>> > "01/01/0001 0.00.00"
> on command window the code I previously posted, I've the wrong output. It
Seems to be one of many limitations of the Command Window, If you try the
code in VB.NET it performs as expected.
I would recommend you change to function to include the "value" parameter as
part of the exceptions,
allowing you can see exactly what the value of "value" is when it fails.
Something like:
Public Property RegistrationDateTime() As DateTime
Get
Return _registrationDateTime
End Get
Set(ByVal value As DateTime)
If value = Nothing Then Throw New ArgumentNullException("value",
"RegistrationDateTime")
If value < New DateTime(2005, 1, 1) Then Throw New
ArgumentOutOfRangeException("value", value, "registrationDateTime must be
after gen, 1 2005")
If value > New DateTime(2025, 1, 1) Then Throw New
ArgumentOutOfRangeException("value", value, "registrationDateTime must be
before gen, 1 2025")
_registrationDateTime = value
End Set
End Property
Hope this helps
Jay
>> > Why this?
>> >
[quoted text clipped - 42 lines]
>
> thanks
Trapulo - 30 Jan 2005 11:13 GMT
Thanks for your suggestion!
> Trapulo,
> In addition to the other comments.
[quoted text clipped - 81 lines]
> >
> > thanks