Name

DateString Property

Class

Microsoft.VisualBasic.DateAndTime

Syntax

DateString(  )

Return Value

A String representing the current system date

Description

Returns or sets a string representing the current system date in the format “mm-dd-yyyy”

Rules at a Glance

The allowed formats for setting the date are “m-d-yyyy,” “m-d-y,” “m/d/yyyy,” and “m/d/y.”

Programming Tips and Gotchas

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

VB .NET/VB 6 Differences

The DateString property is new to VB .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.

Get VB .NET Language in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.