Published in: ASP
URL: http://reusablecode.blogspot.com/2008/04/ordinal-numbers.html
<% ' Copyright (c) 2008, reusablecode.blogspot.com; some rights reserved. ' ' This work is licensed under the Creative Commons Attribution License. To view ' a copy of this license, visit http://creativecommons.org/licenses/by/3.0/ or ' send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California ' 94305, USA. ' Returns the ordinal of a cardinal number. function ordinal(ByVal cardinal) cardinal = CStr(cardinal) if Right(cardinal, 1) = "1" and Right(cardinal, 2) <> "11" then ordinal = cardinal & "st" elseif Right(cardinal, 1) = "2" and Right(cardinal, 2) <> "12" then ordinal = cardinal & "nd" elseif Right(cardinal, 1) = "3" and Right(cardinal, 2) <> "13" then ordinal = cardinal & "rd" else ordinal = cardinal & "th" end if end function ' Unit test 'for i = 0 to 25 ' Response.Write "<p>" & ordinal(i) & "</p>" 'next %>
You need to login to post a comment.
