Public Sub EndOfAddMonthsTest() 'Compare the EndOfAddMonths function to Excel's EOMONTH function. 'Note: You must establish a Reference to atpvbaen.xls within Excel for this to work. Const FmDate = #1/1/1991# Const ToDate = #1/1/1998# Const ForMos = 60 Dim datStart As Date, intOff%, varResES, varResXL For datStart = FmDate To ToDate DoEvents If Day(datStart) = 1 _ And Month(datStart) = 1 Then Debug.Print Now, datStart For intOff = -ForMos To ForMos varResES = EndOfAddMonths(datStart, intOff) varResXL = CDate(EOMONTH(datStart, intOff)) If (IsNull(varResES) And Not IsNull(varResXL)) _ Or (Not IsNull(varResES) And IsNull(varResXL)) _ Or (varResES <> varResXL) Then Debug.Print datStart, intOff, varResXL, varResES, varResES - varResXL End If Next intOff Next datStart End Sub
Copyright 1996-1999 Entisoft
Entisoft Tools is a trademark of Entisoft.