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


VB.NET TimeSpan.FromTicks方法代碼示例

本文整理匯總了VB.NET中System.TimeSpan.FromTicks方法的典型用法代碼示例。如果您正苦於以下問題:VB.NET TimeSpan.FromTicks方法的具體用法?VB.NET TimeSpan.FromTicks怎麽用?VB.NET TimeSpan.FromTicks使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.TimeSpan的用法示例。


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

示例1: FromTicksDemo

' Example of the TimeSpan.FromTicks( Long ) method.
Module FromTicksDemo

    Sub GenTimeSpanFromTicks( ticks As Long )

        ' Create a TimeSpan object and TimeSpan string from 
        ' a number of ticks.
        Dim interval As TimeSpan = TimeSpan.FromTicks( ticks )
        Dim timeInterval As String = interval.ToString( )

        ' Pad the end of the TimeSpan string with spaces if it 
        ' does not contain milliseconds.
        Dim pIndex As Integer = timeInterval.IndexOf( ":"c )
        pIndex = timeInterval.IndexOf( "."c, pIndex )
        If pIndex < 0 Then   timeInterval &= "        "
        
        Console.WriteLine( "{0,21}{1,26}", ticks, timeInterval )
    End Sub 

    Sub Main( )

        Console.WriteLine( _
            "This example of TimeSpan.FromTicks( Long )" & _
            vbCrLf & "generates the following output." & vbCrLf )
        Console.WriteLine( "{0,21}{1,18}", _
            "FromTicks", "TimeSpan" )    
        Console.WriteLine( "{0,21}{1,18}", _
            "---------", "--------" )    

        GenTimeSpanFromTicks( 1 )
        GenTimeSpanFromTicks( 12345 )
        GenTimeSpanFromTicks( 123456789 )
        GenTimeSpanFromTicks( 1234567898765 )
        GenTimeSpanFromTicks( 12345678987654321 )
        GenTimeSpanFromTicks( 10000000 )
        GenTimeSpanFromTicks( 600000000 )
        GenTimeSpanFromTicks( 36000000000 )
        GenTimeSpanFromTicks( 864000000000 )
        GenTimeSpanFromTicks( 18012202000000 )
    End Sub 
End Module 

' This example of TimeSpan.FromTicks( Long )
開發者ID:VB.NET開發者,項目名稱:System,代碼行數:43,代碼來源:TimeSpan.FromTicks

輸出:

FromTicks          TimeSpan
---------          --------
1          00:00:00.0000001
12345          00:00:00.0012345
123456789          00:00:12.3456789
1234567898765        1.10:17:36.7898765
12345678987654321    14288.23:31:38.7654321
10000000          00:00:01
600000000          00:01:00
36000000000          01:00:00
864000000000        1.00:00:00
18012202000000       20.20:20:20.2000000


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