Results 1 to 3 of 3

Thread: Get month names in French?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2012
    Posts
    122

    Get month names in French?

    Hi -- I know that I can get the month name for a date, e.g.:

    Dim myMonth As String = MonthName(Month(myDate))

    which gives me January, February, etc.

    What I need is to *also* get the month name in French, for a bilingual app I'm working on. Note that the app decides the language to display based on values supplied to the program, not the current locale settings.

    Is there a simple, canned way to do this or should I use a lookup array for the month names? Or, something else?

  2. #2
    Frenzied Member MattP's Avatar
    Join Date
    Dec 2008
    Location
    WY
    Posts
    1,227

    Re: Get month names in French?

    Supply the CultureInfo you want to use to the program.

    Code:
        Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
            Dim englishCultureInfo = New Globalization.CultureInfo("en-US")
            Dim frenchCultureInfo = New Globalization.CultureInfo("fr-FR")
    
            Dim d = DateTime.Now
    
            MessageBox.Show(GetMonthName(d, englishCultureInfo))
            MessageBox.Show(GetMonthName(d, frenchCultureInfo))
        End Sub
    
        Private Function GetMonthName(d As DateTime, ci As Globalization.CultureInfo) As String
            Return ci.DateTimeFormat.GetMonthName(d.Month)
        End Function

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jan 2012
    Posts
    122

    Re: Get month names in French?

    Perfect! Thanks!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width