TimeSpan.TicksPerSecond Field

Represents the number of ticks in 1 second.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)

'Declaration
Public Const TicksPerSecond As Long
'Usage
Dim value As Long 

value = TimeSpan.TicksPerSecond

The value of this constant is 10 million; that is, 10,000,000.

The following code example references and displays the value of the TicksPerSecond field.

' Example of the TimeSpan fields. 
Imports System
Imports Microsoft.VisualBasic

Module TimeSpanFieldsDemo

    ' Pad the end of a TimeSpan string with spaces if it does not  
    ' contain milliseconds. 
    Function Align( interval As TimeSpan ) As String 

        Dim intervalStr As String = interval.ToString( )
        Dim pointIndex  As Integer = intervalStr.IndexOf( ":"c )

        pointIndex = intervalStr.IndexOf( "."c, pointIndex )
        If pointIndex < 0 Then intervalStr &= "        "
        Align = intervalStr
    End Function 

    Sub Main( )

        Const numberFmt As String = "{0,-22}{1,18:N0}" 
        Const timeFmt As String = "{0,-22}{1,26}"

        Console.WriteLine( _
            "This example of the fields of the TimeSpan class" & _
            vbCrLf & "generates the following output." & vbCrLf )
        Console.WriteLine( numberFmt, "Field", "Value" )
        Console.WriteLine( numberFmt, "-----", "-----" )

        ' Display the maximum, minimum, and zero TimeSpan values.
        Console.WriteLine( timeFmt, "Maximum TimeSpan", _
            Align( TimeSpan.MaxValue ) )
        Console.WriteLine( timeFmt, "Minimum TimeSpan", _
            Align( TimeSpan.MinValue ) )
        Console.WriteLine( timeFmt, "Zero TimeSpan", _
            Align( TimeSpan.Zero ) )
        Console.WriteLine( )

        ' Display the ticks-per-time-unit fields.
        Console.WriteLine( numberFmt, "Ticks per day", _
            TimeSpan.TicksPerDay )
        Console.WriteLine( numberFmt, "Ticks per hour", _
            TimeSpan.TicksPerHour )
        Console.WriteLine( numberFmt, "Ticks per minute", _
            TimeSpan.TicksPerMinute )
        Console.WriteLine( numberFmt, "Ticks per second", _
            TimeSpan.TicksPerSecond )
        Console.WriteLine( numberFmt, "Ticks per millisecond", _
            TimeSpan.TicksPerMillisecond )
    End Sub  
End Module  

' This example of the fields of the TimeSpan class 
' generates the following output. 
'  
' Field                              Value 
' -----                              ----- 
' Maximum TimeSpan       10675199.02:48:05.4775807 
' Minimum TimeSpan      -10675199.02:48:05.4775808 
' Zero TimeSpan                   00:00:00 
'  
' Ticks per day            864,000,000,000 
' Ticks per hour            36,000,000,000 
' Ticks per minute             600,000,000 
' Ticks per second              10,000,000 
' Ticks per millisecond             10,000

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC, Xbox 360, Zune

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 3.5, 2.0, 1.0

XNA Framework

Supported in: 3.0, 2.0, 1.0
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft