Ticks from a Date
Imports System.Globalization
Module MainClass
Public Sub Main()
Dim numberOfTicks As Long = Int64.MaxValue
Dim validDate As Date
If numberOfTicks >= Date.MinValue.Ticks And _
numberOfTicks <= Date.MaxValue.Ticks Then
validDate = New Date(numberOfTicks)
ElseIf numberOfTicks < Date.MinValue.Ticks Then
Console.WriteLine("{0:N0} is less than {1:N0} ticks.",
numberOfTicks,
DateTime.MinValue.Ticks)
Else
Console.WriteLine("{0:N0} is greater than {1:N0} ticks.",
numberOfTicks,
DateTime.MaxValue.Ticks)
End If
End Sub
End Module
Related examples in the same category