Visual Basic 2005 in a Nutshell (In a Nutshell (OReilly))

DateString Property

Class

Microsoft.VisualBasic.DateAndTime

Syntax

Dim result As String = DateAndTime.DateString

or:

DateAndTime.DateString = newDate

newDate (required in second syntax; String)

A date in string format used to set the current system date

Description

The DateString property gets or sets the current system date. The first syntax returns a string representing the current system date in the "MM-dd-yyyy" format. The second syntax sets the current system date using a string that is in a culture-independent format.

Usage at a Glance

  • The first syntax always returns a date in the format "MM-dd-yyyy."

  • The string in the second syntax must use one of the following date formats: "M-d-yyyy," "M-d-y," "M/d/yyyy," or "M/d/y."

  • See the Format Function entry for details on custom date formats.

  • 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.

  • The security settings of the active user may prevent the system date and time from being altered.

Version Differences

The DateString property is new to VB under .NET. It is a replacement for the VB 6 Date statement, which sets the system date, and the Date and Date$ functions, which retrieve the system date.

See Also

Format Function, Now Property, TimeString Property, Today Property

Категории