如何将日期添加到日期

时间:2013-10-28 07:55:22

标签: vb.net visual-studio-2010 date

所以我只想分享我的问题的答案。所以这是代码:

Private Sub Button2_Click(ByVal sender As System.Object,ByVal e As System.EventArgs)处理Button2.Click
         Dim NextTime As Date = Now
        TextBox1.Text = NextTime.AddDays 在此处设置计数 .0) '例如(100.0) <登记/>     结束次

这可用于截止日期或日期计数器。

1 个答案:

答案 0 :(得分:2)

Dim newDate As DateTime = DateTime.Parse(Label1.Text).AddMonths(6)

Duedate.text = newDate.ToString

您需要确保格式正确,但可以使用以下代码完成:

Dim pattern As String = "MM-dd-yy" 
Dim parsedDate As Date 

   If DateTime.TryParseExact(Label1.Text, pattern, Nothing, 
                             DateTimeStyles.None, parsedDate) Then
      Console.WriteLine("We're good!)
   Else
      Console.WriteLine("Unable to convert")
   End If