Mega Code Archive

 
Categories / VB.Net / Date Time
 

Add a day, a month and a year to a Date

Imports System Public Class MainClass     Shared Sub Main()         Dim dteStartDate As Date         Dim dteChangedDate As Date         'Start off in 2400         dteStartDate = #2/28/2400#         'Add a day and display the results         dteChangedDate = dteStartDate.AddDays(1)         System.Console.WriteLine(dteChangedDate.ToLongDateString)         'Add some months and display the results         dteChangedDate = dteStartDate.AddMonths(6)         System.Console.WriteLine(dteChangedDate.ToLongDateString)         'Subtract a year and display the results         dteChangedDate = dteStartDate.AddYears(-1)         System.Console.WriteLine(dteChangedDate.ToLongDateString)     End Sub End Class