Format Fancy Number (##st, ##nd, ##rd, ##th)
This function adds st, nd, rd, or th to the end of a string of numbers based on what the number is. For example, the following code can produce the following output, "Thursday, November 23rd, 2000" : Format(Date, "dddd, mmmm ") & FormatFancyNumber(Day(Date)) & ", " & Year(Date)
AI
AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.
Source Code
Public Function FormatFancyNumber(ByVal sNumber As String) As String
Dim iTemp As Integer
iTemp = Int(sNumber)
If 4 < iTemp And iTemp < 20 Then
FormatFancyNumber = sNumber & "th"
Else
Select Case iTemp Mod 10
Case 1
FormatFancyNumber = sNumber & "st"
Case 2
FormatFancyNumber = sNumber & "nd"
Case 3
FormatFancyNumber = sNumber & "rd"
Case Else
FormatFancyNumber = sNumber & "th"
End Select
End If
End Function
Original Comments (3)
Recovered from Wayback Machine