本文整理匯總了VB.NET中System.DateTime.AddHours方法的典型用法代碼示例。如果您正苦於以下問題:VB.NET DateTime.AddHours方法的具體用法?VB.NET DateTime.AddHours怎麽用?VB.NET DateTime.AddHours使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.DateTime
的用法示例。
在下文中一共展示了DateTime.AddHours方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: Example
Module Example
Public Sub Main()
Dim hours() As Double = {.08333, .16667, .25, .33333, .5, .66667, 1, 2, _
29, 30, 31, 90, 365}
Dim dateValue As Date = #3/1/2009 12:00#
For Each hour As Double In hours
Console.WriteLine("{0} + {1} hour(s) = {2}", dateValue, hour, _
dateValue.AddHours(hour))
Next
End Sub
End Module
' The example displays the following output on a system whose current
' culture is en-US:
' 3/1/2009 12:00:00 PM + 0.08333 hour(s) = 3/1/2009 12:04:59 PM
' 3/1/2009 12:00:00 PM + 0.16667 hour(s) = 3/1/2009 12:10:00 PM
' 3/1/2009 12:00:00 PM + 0.25 hour(s) = 3/1/2009 12:15:00 PM
' 3/1/2009 12:00:00 PM + 0.33333 hour(s) = 3/1/2009 12:19:59 PM
' 3/1/2009 12:00:00 PM + 0.5 hour(s) = 3/1/2009 12:30:00 PM
' 3/1/2009 12:00:00 PM + 0.66667 hour(s) = 3/1/2009 12:40:00 PM
' 3/1/2009 12:00:00 PM + 1 hour(s) = 3/1/2009 1:00:00 PM
' 3/1/2009 12:00:00 PM + 2 hour(s) = 3/1/2009 2:00:00 PM
' 3/1/2009 12:00:00 PM + 29 hour(s) = 3/2/2009 5:00:00 PM
' 3/1/2009 12:00:00 PM + 30 hour(s) = 3/2/2009 6:00:00 PM
' 3/1/2009 12:00:00 PM + 31 hour(s) = 3/2/2009 7:00:00 PM
' 3/1/2009 12:00:00 PM + 90 hour(s) = 3/5/2009 6:00:00 AM
' 3/1/2009 12:00:00 PM + 365 hour(s) = 3/16/2009 5:00:00 PM