[INCLUDE]
IsGregYear

[CODE]
Public Function DateTripleToLong(ByVal xYear As Long, ByVal xMonth As Long, ByVal xDay As Long) As Long
  Dim xGreg As Long
  
  xGreg = -CLng(IsGregYear(xYear))
  xYear = xYear - 1&
  DateTripleToLong = Fix(xYear / 400&) * 146097
  xYear = xYear Mod 400&
  DateTripleToLong = DateTripleToLong + Fix(xYear / 100) * 36524
  xYear = xYear Mod 100&
  DateTripleToLong = DateTripleToLong + Fix(xYear / 4&) * 1461&
  xYear = xYear Mod 4&
  DateTripleToLong = DateTripleToLong + xYear * 365&
  
  Select Case xMonth
    Case 1&: xGreg = 0&
    Case 2&: DateTripleToLong = DateTripleToLong + 31&: xGreg = 0&
    Case 3&: DateTripleToLong = DateTripleToLong + 59&
    Case 4&: DateTripleToLong = DateTripleToLong + 90&
    Case 5&: DateTripleToLong = DateTripleToLong + 120&
    Case 6&: DateTripleToLong = DateTripleToLong + 151&
    Case 7&: DateTripleToLong = DateTripleToLong + 181&
    Case 8&: DateTripleToLong = DateTripleToLong + 212&
    Case 9&: DateTripleToLong = DateTripleToLong + 243&
    Case 10&: DateTripleToLong = DateTripleToLong + 273&
    Case 11&: DateTripleToLong = DateTripleToLong + 304&
    Case 12&: DateTripleToLong = DateTripleToLong + 334&
    End Select
  
  DateTripleToLong = DateTripleToLong + xDay + xGreg
  End Function
