本文整理汇总了VB.NET中Microsoft.VisualBasic.DateAndTime.DateAdd方法的典型用法代码示例。如果您正苦于以下问题:VB.NET DateAndTime.DateAdd方法的具体用法?VB.NET DateAndTime.DateAdd怎么用?VB.NET DateAndTime.DateAdd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。
在下文中一共展示了DateAndTime.DateAdd方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: DateAdd
Dim dateEntered As String =
InputBox("Enter a date", DefaultResponse:=Date.Now.ToShortDateString)
Dim monthsEntered As String =
InputBox("Enter number of months to add", DefaultResponse:="12")
Dim dateValue As Date = Date.Parse(dateEntered)
Dim monthsValue As Integer = Integer.Parse(monthsEntered)
' Add the months to the date.
Dim newDate As Date = DateAdd(DateInterval.Month, monthsValue, dateValue)
' This statement has a string interval argument, and
' is equivalent to the above statement.
'Dim newDate As Date = DateAdd("m", monthsValue, dateValue)
MessageBox.Show("New date: " & newDate.ToShortDateString)