Returns or sets a String value representing the current date according to your system.
Public Property DateString As String
| Exception type | Error number | Condition |
|---|---|---|
| 5 | Invalid cast. |
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".
If you attempt to set DateString with an invalid value, an InvalidCastException occurs.
To get or set the current system time as a String, use the TimeString property.
To access the current system date as a Date, use the Today property.
This example uses the DateString property to display the current system date.
MsgBox("The current date is " & DateString)
Namespace: Microsoft.VisualBasic
Module: DateAndTime
Assembly: Microsoft Visual Basic .NET Runtime (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.
Now Property | TimeString Property | Today Property |