當前位置: 首頁>>代碼示例>>VB.NET>>正文


VB.NET DateAndTime.DateDiff方法代碼示例

本文整理匯總了VB.NET中Microsoft.VisualBasic.DateAndTime.DateDiff方法的典型用法代碼示例。如果您正苦於以下問題:VB.NET DateAndTime.DateDiff方法的具體用法?VB.NET DateAndTime.DateDiff怎麽用?VB.NET DateAndTime.DateDiff使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。


在下文中一共展示了DateAndTime.DateDiff方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。

示例1: InputBox

Dim date2Entered As String = InputBox("Enter a date")

Try
    Dim date2 As Date = Date.Parse(date2Entered)
    Dim date1 As Date = Now

    ' Determine the number of days between the two dates.
    Dim days As Long = DateDiff(DateInterval.Day, date1, date2)

    ' This statement has a string interval argument, and
    ' is equivalent to the above statement.
    'Dim days As Long = DateDiff("d", date1, date2)

    MessageBox.Show("Days from today: " & days.ToString)
Catch ex As Exception
    MessageBox.Show("Invalid Date: " & ex.Message)
End Try
開發者ID:VB.NET開發者,項目名稱:Microsoft.VisualBasic,代碼行數:17,代碼來源:DateAndTime.DateDiff

示例2: DateDiff

' The following statements set datTim1 to a Thursday
' and datTim2 to the following Tuesday.
Dim datTim1 As Date = #1/4/2001#
Dim datTim2 As Date = #1/9/2001#
' Assume Sunday is specified as first day of the week.
Dim wD As Long = DateDiff(DateInterval.Weekday, datTim1, datTim2)
Dim wY As Long = DateDiff(DateInterval.WeekOfYear, datTim1, datTim2)
開發者ID:VB.NET開發者,項目名稱:Microsoft.VisualBasic,代碼行數:7,代碼來源:DateAndTime.DateDiff

示例3:

Dim startTime As Date = Now
' Run the process that is to be timed.
Dim runLength As Global.System.TimeSpan = Now.Subtract(startTime)
Dim millisecs As Double = runLength.TotalMilliseconds
開發者ID:VB.NET開發者,項目名稱:Microsoft.VisualBasic,代碼行數:4,代碼來源:DateAndTime.DateDiff


注:本文中的Microsoft.VisualBasic.DateAndTime.DateDiff方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。