I was reviewing code for a Visual Basic 6 application I'm maintaining when I saw this code:
ComboDay.Clear
For i = 0 To DaysPerMonth(iMonth)
ComboDay.AddItem i
Next i
It populates a drop-down list with the number of days in a month. The DaysPerMonth array is created earlier and looks like this:
DaysPerMonth(1) = 31
DaysPerMonth(2) = 28
...
DaysPerMonth(12) = 31
So, what about the number of days in February in a leap year?
If (Val(CurrentYear) Mod 4) = 0 Then DaysPerMonth(2) = 29
The application only deals with years after 2000 but this last line of code made me cringe.
[Moved to Sidebar where it seems more appropriate. -ShadowMod]