Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
 
 
 
500MB 27GB Web Hosting - $9.95/Month
 
 
 
 
 
Old Pages
 
Old Index
Site Map
What's New
 
Books
How To
Tips & Tricks
Tutorials
Stories
Performance
Essays
Links
Q & A
New in VB6
Free Stuff
Pictures
 
 
 
TitleFind ordinal extensions (as in 1st, 2nd, 143rd, etc.)
Keywordsordinal extension, 1st, 2nd, 3rd
CategoriesAlgorithms, Strings
 
By Peter Chamberlin.
 
' Extend Date Number to Include Text Suffix
Public Function DateExtension(ByVal DateNum) As String
Dim DateRemainder As Integer

   ' Default to Most Common Extension
   DateExtension = "th"

   ' Handle ?11th through ?13th
   DateRemainder = DateNum Mod 100

   ' If Not An Exception
   If DateRemainder < 11 Or DateRemainder > 13 Then

      ' Get Right Digit
      Select Case DateNum Mod 10

         ' Update Appropriate Extension
         Case 1: DateExtension = "st"
         Case 2: DateExtension = "nd"
         Case 3: DateExtension = "rd"

      End Select

   End If

   ' Add Extension to Original Number
   DateExtension = DateNum & DateExtension

End Function
 
 
Copyright © 1997-2003 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated