Export (0) Print
Expand All

DateAndTime.TimeString Property

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

Namespace:  Microsoft.VisualBasic
Assembly:  Microsoft.VisualBasic (in Microsoft.VisualBasic.dll)

static member TimeString : string with get, set

Property Value

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

ExceptionCondition
InvalidCastException

Invalid format used to set the value of TimeString.

TimeString always returns the system time as "HH:mm:ss", which is a 24-hour format. This format is culture-invariant, which means it does not change even if you change the Regional Options in Control Panel.

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

To get the current system date or time in the format of your locale, or in a custom format, supply the Now property to the Format function, specifying either a predefined or user-defined date/time format. The following example demonstrates this.

MsgBox("The formatted time is " & Format(Now, "hh.mm.ss.fff tt"))

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

Security noteSecurity Note

Setting the system date or time requires unmanaged code permission, which might affect its execution in partial trust situations. For more information, see SecurityPermission and Code Access Permissions.

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

MsgBox("The current time is " & TimeString)

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft