Public Class MainClass
Public Shared Function GetOrdinal(ByVal Number As Integer) As String
If CType(Number, String).Length > 2 Then
Dim intEndNum As Integer = CType(CType(Number, String).Substring(CType(Number, String).Length - 2, 2), Integer)
If intEndNum >= 11 And intEndNum <= 13 Then
Select Case intEndNum
Case 11, 12, 13
Return "th"
End Select
End If
End If
If Number >= 21 Then
Select Case CType(Number.ToString.Substring(Number.ToString.Length - 1, 1), Integer)
Case 1
Return "st"
Case 2
Return "nd"
Case 3
Return "rd"
Case 0, 4 To 9
Return "th"
End Select
Else
Select Case Number
Case 1
Return "st"
Case 2
Return "nd"
Case 3
Return "rd"
Case 4 To 20
Return "th"
End Select
End If
End Function
Public Shared Sub Main
System.Console.WriteLine(GetOrdinal("123"))
End Sub
End Class