数据类型:TimeSpan

TimeSpan 实例的值表示一个时间段。该值是实例中包含的刻度数,其范围可以在 Int64.MinValue 到 Int64.MaxValue 之间。

        Dim strMsg As String = "离国庆节还有{0}天。"
        Dim nowdt As DateTime = DateTime.Now.Date
        Dim nextDt As DateTime = New DateTime(nowdt.Year, 10, 1)
        Dim nDay As TimeSpan = nextDt.Subtract(nowdt)

        MessageBox.Show(String.Format(strMsg, nDay.Days.ToString))

       以前常用 DateDiff(DateInterval.Day, nowdt, nextDt)

你可能感兴趣的:(VB.Net)