A hash lookup? Why not an array? Anyway, i wouldnt have laughed so hard if it had been written something like the following:
Public Function GetMonthName(ByVal m As Long, _ Optional ByVal abbr As Boolean = False) As String Static Months(12) As String If (Months(1) <> "January") Then Months(1) = "January" Months(2) = "February" Months(3) = "March" Months(4) = "April" Months(5) = "May" Months(6) = "June" Months(7) = "July" Months(8) = "August" Months(9) = "September" Months(10) = "October" Months(11) = "November" Months(12) = "December" End If Dim tmp As String If (m >= 1 And m <= 12) Then tmp = Months(m) Else tmp = Format(m, "0") End If If abbr Then GetMonthName = Left(tmp, 3) Else GetMonthName = tmp End If End Function
First they ignore you, then they laugh at you, then they fight you, then you win.
-- Gandhi
In reply to Re^4: The joys of bad code
by demerphq
in thread The joys of bad code
by BUU
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |