Visual Basic .NET provides the versatile Date data type to store date and time values. The following lines of code are examples of using date variables:
Dim dtWWII As Date = #12/7/1941# Dim dtKing As Date = Convert.ToDateTime("Aug 16, 1977 4:00 PM") Dim dtJFK As Date = Convert.ToDateTime("November 23, 1963") Dim dtMoon As New Date(1969, 7, 20)
The first line of the previous code uses the pound (#) symbol to assign a date value directly to a variable of type date. The next two examples use methods to convert strings containing date and time expressions to the Date type. The final line of code shows how the constructor method can be used to initialize a date by supplying parameters for the year, month, and day.