The Ordinal Number Function
This is a comment thread discussing The Ordinal Number Function
  • 11 years ago
    May I offer this much simpler version: Public Function ToOrdinal(ByVal value As Integer) As String If value Mod 100 > 10 And value Mod 100 < 20 Then Return value.ToString & "th" Else Select Case value Mod 10 Case 1 Return value.ToString & "st" Case 2 Return value.ToString & "nd" Case 3 Return value.ToString & "rd" Case Else Return value.ToString & "th" End Select End If End Function

Post a reply

Enter your message below

Sign in or Join us (it's free).


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil.” - Donald Knuth