Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


vb6 project to handle european languages

Posted on 2001-07-24
Medium Priority
Last Modified: 2008-02-01
How can i make my vb6 project to support different european languages. i have log all the string that the  program display, i have over 2000 different strings. i was thinking of using resource files ?? is this the only way ??? if not what is the better way ?? please help.
Question by:LPlate
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Expert Comment

ID: 6311994
I had to do this for a project which needed to be able to change the language at runtime without a restart.

We used an Access database (3000 strings) and used the AbsolutePosition settings to get each string.

It means loading the strings on each form as the form loads, but it does not seem to take much time for us since we open the recordset at program startup to keep all the strings ready.

A simple function call like GetString(1023) will return the string in the recordset at position 1023:>

Function GetString(TheNO as Long)
    MyLangStr.AbsolutePosition = TheNo
    GetString = MyLangStr.Fields("String")
End Function

Dont know if this will help you but it may be an idea to give it a try. One thing though. You CANNOT delete or move items in the database sine this will mess up the AbsolutePosition of all the others.

Good luck...


Expert Comment

ID: 6311998
Forgot to mention that of course in the example above, the recordset MyLangStr is global. It gets opened when the program starts and is ready to go while it is running.

Good Luck...

Expert Comment

ID: 6312003
If you don't want to use a resource file you could put a string ID in the Tag property of each control that will use a string.

Put all of your multi language strings into a database file with a language code and the string ID as the key.

When you start the application ask the user for a language code or retrieve it from the registry.

When you load the form read through all of the controls on it and if the Tag property contains a value, go and get the appropriate record from the database and populate the control's Text or Caption property.

Here's a routine for reading through all of the controls on a form.

Public Sub ShowMandatoryControls(myForm As Form)
   'Set the background and foreground colours for text boxes
   'depending on whether they're mandatory and/or empty
   Dim myControl As Control
   For Each myControl In myForm.Controls
      If TypeOf myControl Is TextBox Or _
         TypeOf myControl Is DataCombo Then
         If UCase(myControl.Tag) = "M" And _
            Trim(myControl.Text) = "" Then
            myControl.BackColor = vbYellow
            myControl.ForeColor = vbBlack
            myControl.BackColor = vbWindowBackground
            myControl.ForeColor = vbWindowText
         End If
      End If

End Sub

I guess, when it comes down to it, that's what resource files are doing!
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.


Expert Comment

ID: 6312736
There are two ways to go here:

1. Use a resource file with multiple string tables, one for each language you wish to use.

Resource files created with the Resource Editor can contain multiple string tables, each containing strings localized for a different language. A string table will automatically be selected at run-time based on the LCID of the system; if a match isn?t found the system will load the first string table in the resource file. This model is advantageous for creating an application which will be distributed for two or more languages with no requirement for multi-language support within a single instance.

2. If you wish to dynamically select the language i.e. at run time then you can use the following approach.

Ok there is a way of doing this without changing the default locale on the machine.

Create two new ActiveX DLL projects (number of projects depends on the number of languages required
but for this example two will suffice).

Name the projects as follows

Rename Class1 in both cases Resource

Using the Resource Add in in Visual basic add a resource to each project name the .Res files LocaleEnglish
and LocaleIrish.

Just for example add "How Are You" to the LocaleEnglish resource and "Conas ata tu" to the LocaleIrish

Add the following code to each class module.

Public Function GetResourceString(ResourceIndex As Long) As String
        GetResourceString = LoadResData(ResourceIndex, 6)
End Function

Make both ActiveX DLLs. Save the projects and close them.

You now have a means of switching between resources in your code.

Just do the following and test it.

Dim objLocalised as Object
Dim strLanguage as String
strLanguage = "English"

objLocalised = CreateObject("Locale" + strLanguage + ".Resource")

Dim strTemp as String  
strTemp = objLocalised.GetResourceString(101)

If you change the strLanguage to "Irish" you will get the Irish version of 'How are you'.

Just repeat the process for the required languages.

That should be it.


LVL 49

Expert Comment

ID: 7161467
Hi LPlate,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Save as PAQ -- No Refund.
    *** 3 Good answers, too few points to split.  Accepting recommendations, though.

LPlate, Please DO NOT accept this comment as an answer.
EXPERTS: Post a comment if you are certain that an expert deserves credit.  Explain why.
DanRollins -- EE database cleanup volunteer

Accepted Solution

Computer101 earned 0 total points
ID: 7182599
Placed in PAQ

E-E Moderator

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question ( in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question