views:

1187

answers:

4

Hello,

The title says it all really, is there a built in VB.NET function to format a number as an Ordinal?

Or do I have to write my own?

There isn't in C# so I'm thinking their isn't :(

Thanks

+1  A: 

There is an article here related to the topic: http://snipplr.com/view/8324/add-ordinal/

+1  A: 

If an implementation were available for VB.NET, it would be available for C# as well - you can call into the VB-specific "standard libraries" from C#.

In other words - I don't believe there's anything in the framework.

Jon Skeet
+1  A: 

Already answered in Ordinals in C# Search is your friend . . .

Basically "No, there is no method provided in the framework", but there are good answers about how to do it.

EDIT

Apologies to whom ever thought I deserved the downvote, I should have translated the C# to vb.net.

Public Function AddOrdinal(ByVal num As Integer) as String
    Select Case (num Mod 100)
        Case 11
        Case 12
        Case 13
            Return num.ToString() + "th"
    End Select
    Select Case num Mod 10
        Case 1
            Return num.ToString() + "st"
        Case 2
            Return num.ToString() + "nd"
        Case 3
            Return num.ToString() + "rd"
        Case Else
            Return num.ToString() + "th"
    End Select
End Function
Binary Worrier
A: 

Lines 3-5 of the code above should be replaced with: Case 11, 12, 13

VB.NET does not continue executing case clauses as in C++ - there is no 'break' statement.