DateValue Function (Visual Basic)
Returns a Date value containing the date information represented by a string, with the time information set to midnight (00:00:00).
StringDate includes invalid time information.
See the "Error number" column if you are upgrading Visual Basic 6.0 applications that use unstructured error handling. (You can compare the error number against the Number Property (Err Object).) However, when possible, you should consider replacing such error control with Structured Exception Handling Overview for Visual Basic.
If StringDate includes only numbers from 1 through 12 separated by valid date separators, DateValue recognizes the order for month, day, and year according to the Short Date format specified for your system. DateValue uses the current calendar setting from the CurrentCulture property of the CultureInfo class in the System.Globalization namespace. The default CurrentCulture values are determined by Control Panel settings. You can override the Short Date format by setting the ShortDatePattern property of the DateTimeFormatInfo class in the System.Globalization namespace.
DateValue recognizes month names in long, abbreviated, and numeric form. For example, in addition to recognizing 12/30/1991 and 12/30/91, DateValue also recognizes December 30, 1991 and Dec 30, 1991.
If the year part of StringDate is omitted, DateValue uses the current year from your computer's system date.
If the StringDate argument includes time information, DateValue does not include it in the returned value. However, if StringDate includes invalid time information, such as "89:98", an InvalidCastException error occurs.
Assembly: Visual Basic Runtime Library (in Microsoft.VisualBasic.dll)