本文整理匯總了VB.NET中System.TimeSpan.FromSeconds方法的典型用法代碼示例。如果您正苦於以下問題:VB.NET TimeSpan.FromSeconds方法的具體用法?VB.NET TimeSpan.FromSeconds怎麽用?VB.NET TimeSpan.FromSeconds使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.TimeSpan
的用法示例。
在下文中一共展示了TimeSpan.FromSeconds方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: FromSecondsDemo
' Example of the TimeSpan.FromSeconds( Double ) method.
Module FromSecondsDemo
Sub GenTimeSpanFromSeconds( seconds As Double )
' Create a TimeSpan object and TimeSpan string from
' a number of seconds.
Dim interval As TimeSpan = _
TimeSpan.FromSeconds( seconds )
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}", seconds, timeInterval )
End Sub
Sub Main( )
Console.WriteLine( "This example of " & _
"TimeSpan.FromSeconds( Double )" & _
vbCrLf & "generates the following output." & vbCrLf )
Console.WriteLine( "{0,21}{1,18}", _
"FromSeconds", "TimeSpan" )
Console.WriteLine( "{0,21}{1,18}", _
"-----------", "--------" )
GenTimeSpanFromSeconds( 0.001 )
GenTimeSpanFromSeconds( 0.0015 )
GenTimeSpanFromSeconds( 12.3456 )
GenTimeSpanFromSeconds( 123456.7898 )
GenTimeSpanFromSeconds( 1234567898.7654 )
GenTimeSpanFromSeconds( 1 )
GenTimeSpanFromSeconds( 60 )
GenTimeSpanFromSeconds( 3600 )
GenTimeSpanFromSeconds( 86400 )
GenTimeSpanFromSeconds( 1801220.2 )
End Sub
End Module
' This example of TimeSpan.FromSeconds( Double )
輸出:
FromSeconds TimeSpan ----------- -------- 0.001 00:00:00.0010000 0.0015 00:00:00.0020000 12.3456 00:00:12.3460000 123456.7898 1.10:17:36.7900000 1234567898.7654 14288.23:31:38.7650000 1 00:00:01 60 00:01:00 3600 01:00:00 86400 1.00:00:00 1801220.2 20.20:20:20.2000000