>> blnDate_Valid = IsDate(x)
Should result in False, but throws exception:
Actually, I still think this is an error in VB.NET. I don't understand why
IsDate allows an internally-thrown exception to be caught by the procedure
that calls it. For example, consider the following code:
Dim s As String
s = "Blah"
Debug.WriteLine(IsNumeric(s))
Debug.WriteLine(IsDate(s))
If you run that with the IDE set to break on CLR exceptions, it successfully
processes the IsNumeric() call without any problems, but then breaks into
the IDE on the IsDate() call. This seems inconsistent to me.
The exception can't even be caught by the calling procedure. For example:
Try
Debug.WriteLine(IsDate(s))
Catch ex As Exception
Debug.WriteLine("Error: " & ex.Message)
End Try
Run this with the IDE set NOT to break and you'll find that the exception is
not caught. So there's no reason to allow the IDE to know that an exception
occurred.
IsDate() is the only function in the entire language runtime that I've found
that exhibits this behaviour.
It's also darned annoying. :) I like to run my code with the IDE always set
to break on exceptions as I find it much easier to track problems down if I
can immediately see where the exception occurred. I've had to write a
wrapper around IsDate() that performs some basic validation (not an empty
string, first character is numeric, etc.) before it calls into IsDate in an
attempt to weed out as many non-date values as I can. :-/
Hopefully this will change in VS2005.
--
(O) e n o n e