TimeValue Function (Visual Basic)
Returns a Date value containing the time information represented by a string, with the date information set to January 1 of the year 1.
Public Function TimeValue(ByVal StringTime As String) As DateTime
|
Exception type |
Error number |
Condition |
|---|---|---|
|
StringTime includes invalid date 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.
You can enter valid times using a 12-hour or 24-hour clock. For example, "2:24 P.M." and "14:24" are both valid StringTime arguments.
If the StringTime argument includes date information, TimeValue does not include it in the returned value. However, if StringTime includes invalid date information, for example "January 32," an InvalidCastException error occurs.
Namespace: Microsoft.VisualBasic
Module: DateAndTime
Assembly: Visual Basic Runtime Library (in Microsoft.VisualBasic.dll)