This documentation is archived and is not being maintained.

TimeString Property

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

Public Property TimeString As String


Exception type Error number Condition
InvalidCastException 5 Invalid cast.


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.


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

MsgBox("The current time is " & TimeString)


Namespace: Microsoft.VisualBasic

Module: DateAndTime

Assembly: Microsoft Visual Basic .NET Runtime (in Microsoft.VisualBasic.dll)

Because TimeString is a member of a module, rather than of a class, you do not need to create an object on which to access TimeString.

See Also

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