Returns or sets a String value representing the current date according to your system.
|Exception type||Error number||Condition|
Invalid format used to set value of DateString.
See the "Error number" column if you are upgrading Visual Basic 6.0 applications that use unstructured error handling. (You can compare the error number against the.) However, when possible, you should consider replacing such error control with .
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.
To get the current system date or time in the format of your locale, or in a custom format, supply theto the , specifying either or . 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.
Setting the system date or time requires unmanaged code permission, which might affect its execution in partial-trust situations. For more information, seeand .
Assembly: Visual Basic Runtime Library (in Microsoft.VisualBasic.dll)
Because DateString is a member of a module, rather than of a class, you do not need to create an object on which to access DateString.