Change language for calendar control in VB6

jadixon04 used Ask the Experts™
I have code written in VB6 and C++ that I cannot upgrade or change to .net.  We are currently using the DTPicker for our calendar control.  Our customers use a variety of codepages as their default, but we need to return the Month within the date in a specific language (not their local codepage).  Is there any way I can write code to force the Month to be returned in a specific language?  For example, our customer is using the Ukranian codepage, but we need to return the month in the Russian codepage language.  We would prefer not to use a different calendar control if possible.
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®


Upon further research we have found that our code is using different types of calendar controls between the VB and C++, with different processing built around some of the C++.  We cannot use any different types of controls, so we cannot use the suggested tools.  I will close this question since we must regroup and determine how we will deal with the different controls.
I don't think you need new controls. Just format the return value from DtPicker as follows:

The return value from DTPicker is actually a Vb Double.
Thus you can use this value to get the Month Name (either abbreviated or full) for any language by specifyinbg the LCID in the following code:

Private Sub DTPicker1_Change()
    lblEnglish.Caption = GetMonthName(DTPicker1.Value, 1033, False)
    lblRussian.Caption = GetMonthName(DTPicker1.Value, 1049, False)
    lblFrench.Caption = GetMonthName(DTPicker1.Value, 1036, False)
End Sub

'In module
Option Explicit
Private Const LOCALE_SMONTHNAME1  As Long = &H38
Private Const LOCALE_SABBREVMONTHNAME1  As Long = &H44
Private Declare Function GetLocaleInfoA Lib "kernel32" (ByVal Locale As Long, ByVal LCType As Long, ByVal lpLCData As String, ByVal cchData As Long) As Long
Public Function GetMonthName(ByVal dat As Date, ByVal LCID As Long, ByVal bAbbreviated As Boolean)
   Dim Buffer     As String * 255
   GetLocaleInfoA LCID, Month(dat) - 1 + IIf(bAbbreviated, LOCALE_SABBREVMONTHNAME1, LOCALE_SMONTHNAME1), Buffer, 255
   GetMonthName = StripNull(Buffer)
End Function
Private Function StripNull(ByVal StrIn As String) As String
   Dim nul              As Long
   nul = InStr(StrIn, vbNullChar)
   Select Case nul
      Case Is > 1
         StripNull = Left$(StrIn, nul - 1)
      Case 1
         StripNull = ""
      Case 0
         StripNull = Trim$(StrIn)
   End Select
End Function

Open in new window


This has helped set me on a track to possibly finding a solution for part of my problem. I think it will require more research and work, but I have a higher priority project at the moment (unfortunately).

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial