Export (0) Print
Expand All

DateAndTime.DateString Property

Returns or sets a String value representing the current date according to your system.

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

public static string DateString { get; set; }
/** @property */
public static String get_DateString ()

/** @property */
public static void set_DateString (String Value)

public static function get DateString () : String

public static function set DateString (Value : String)

Not applicable.

Property Value

Returns or sets a String value representing the current date according to your system.

For more detailed information, see the Visual Basic topic DateString Property.

DateString always returns the system date as "MM-dd-yyyy", which uses the abbreviated month name. The accepted formats for setting the date are "M-d-yyyy", "M-d-y", "M/d/yyyy", and "M/d/y". These formats are culture-invariant, which means they do not change even if you change the Regional Options in Control Panel.

To get or set the current system time as a String, use the TimeString 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 Predefined Date/Time Formats (Format Function) or User-Defined Date/Time Formats (Format Function). The following example demonstrates this.

MsgBox("The formatted date is " & Format(Now, "dddd, d MMM yyyy"))

To access the current system date as a Date, use the Today 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.

The following example uses the DateString property to display the current system date.

MsgBox("The current date is " & DateString)

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

Community Additions

ADD
Show:
© 2015 Microsoft