TimeValue (function)

Syntax

TimeValue(time_string$)

Description

Returns a Date variant representing the time contained in the specified string argument.

Comments

This function interprets the passed time_string$ parameter looking for a valid time specification.

The time_string$ parameter can contain valid time items separated by time separators such as colon (:) or period (.).

 

Time strings can contain an optional date specification, but this is not used in the formation of the returned value.

If a particular time item is missing, then it is set to 0. For example, the string "10 pm" would be interpreted as "22:00:00."

Example

This example calculates the TimeValue of the current time and displays it in a dialog box.

Sub Main()
  t1$ = "10:15"
  t2# = TimeValue(t1$)
  MsgBox "The TimeValue of " & t1$ & " is: " & t2#
End Sub

See Also

DateValue (function); TimeSerial (function); DateSerial (function).

More information

T