Visual Basic Language Reference  

TimeString Property

Returns or sets a String value representing the current time of day according to your system.

Public Property TimeString As String

Exceptions/Errors

Exception type Error number Condition
InvalidCastException 5 Invalid cast.

Remarks

TimeString always returns the system time as "HH:mm:ss", which is a 24-hour format.

If you attempt to set TimeString with an invalid value, an InvalidCastException occurs.

To get or set the current system date as a String, use the DateString property.

To access the current system time as a Date, use the TimeOfDay property.

Example

This example uses the TimeString property to display the current system time.

MsgBox("The current time is " & TimeString)

See Also

Now Property | DateString Property | TimeOfDay Property | System Namespace | DateTime Structure | ArgumentException