• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 923
  • Last Modified:

Change language for calendar control in VB6

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.
  • 2
  • 2
1 Solution
jadixon04Author Commented:
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

jadixon04Author Commented:
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).
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now