Hi All,
Here's a quick and nasty function to convert a number to it's ordinal representation.
e.g.
1 = 1st
2 = 2nd
3 = 3rd
etc.
Hope it's useful for someone.!
All the best
Marc
Here's a quick and nasty function to convert a number to it's ordinal representation.
e.g.
1 = 1st
2 = 2nd
3 = 3rd
etc.
Code:
Public Function IntToOrdinalString(MyNumber As Integer) As String
Dim sOutput As String
Dim iUnit As Integer
iUnit = MyNumber Mod 10
sOutput = ""
Select Case MyNumber
Case Is < 0
sOutput = ""
Case 10 To 19
sOutput = "th"
Case Else
Select Case iUnit
Case 0 'Zeroth only has a meaning when counts start with zero, which happens in a mathematical or computer science context.
sOutput = "th"
Case 1
sOutput = "st"
Case 2
sOutput = "nd"
Case 3
sOutput = "rd"
Case 4 To 9
sOutput = "th"
End Select
End Select
IntToOrdinalString = CStr(MyNumber) & sOutput
End Function
Hope it's useful for someone.!
All the best
Marc