2009-11-03 10 views

Répondre

1

Ce probablement la meilleure approche: -

private static string[] dayText = new string[] 
{"First", "Second", "Third", "Fourth", "Fifth", "Sixth", "Seventh", "Eighth", 
"Nineth", "Tenth", "Eleventh", "Twelveth", "Thirteenth", "Fourteenth", "Fifteenth", 
    "Sixteenth", "Seventeenth", "Eighteenth", "Nineteenth", "Twentieth", "Twenty first", 
"Twenty second", "Twenty third", "Twenty fourth", "Twenty fifth", "Twenty sixth", 
"Twenty seventh", "Twenty eighth", "Twenty nineth", "Thirtieth", "Thirty first"}; 

public static string DayInWords(int day) 
{ 
    //assertion code here 
    return dayText[day-1]; 
} 

... 
string result = DayInWords(myDate.Day) + myDate.ToString(" MMM yyyy"); 
0

Je ne connais aucune fonction intégrée. Mais il n'y a que 31 jours à considérer. Il serait assez facile de construire une fonction qui remplaçait manuellement 1 à 31 par des mots. Puis ajouter le mois et l'année, comme dans:

Function foobar(ByVal mydate As Date) As String 

Dim result As String = "" 
Select Case mydate.Day 
    Case 1 
     result = "First" 
     Case 2 
      result = "Second" 
     Case 3 
      result = "Third" 

     ... etc ... 

     Case 31 
     result = "Thirty-First" 
End Select 
Return result & " " & mydate.ToString("MMMM yyyy") 
End Function