VB.net如何时间相减,我正在做一个提示还书的窗口,怎么让现在日期减去当时借书的日期,然后显示出小于5天
1个回答
展开全部
给你个例子:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim MyEndDate As New DateTime(2012, 8, 8)
Dim MyStartDate As DateTime = DateTime.Now
Dim MySpan As TimeSpan = MyEndDate.Subtract(MyStartDate)
Dim MyInfo As String = "离2012年8月8日还有" + _
Math.Round(MySpan.TotalDays, 0).ToString() + "天"
MessageBox.Show(MyInfo, "信息", _
MessageBoxButtons.OK, MessageBoxIcon.Information)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim MyEndDate As New DateTime(2012, 8, 8)
Dim MyStartDate As DateTime = DateTime.Now
Dim MySpan As TimeSpan = MyEndDate.Subtract(MyStartDate)
Dim MyInfo As String = "离2012年8月8日还有" + _
Math.Round(MySpan.TotalDays, 0).ToString() + "天"
MessageBox.Show(MyInfo, "信息", _
MessageBoxButtons.OK, MessageBoxIcon.Information)
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询