Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleLoad internationalization data from a resource file with multiple string tables
Keywordsdatabase, internationalization, language, resource file
CategoriesDatabase, Software Engineering
 
To install the resource editor, select the Add-In menu's Add-In Manager command. Click on the VB 6 Resource Editor. Check the Load/Unload and Load on Startup boxes. Then click Ok.

At the bottom of the Project menu, select Add New Resource File command. Now you can use the resource editor to edit the resource file.

This example uses three string tables to store values. For example, the "yes" value is stored as "Yes" in the English table, "Oui" in the French table, and "Ja" in the German table. All three strings have the same identifier.

These tables are identified as English, French, and German in the resource file.

When it runs, the application automatically selects the right table based on the system's LCID. If the LCID doesn't match a table, the application uses the first table.

The program uses LoadResData, LoadResPicture, and LoadResString to load its data.

 
Private Enum PictureIDs
    respicYes = 10001
    respicNo = 10002
End Enum

Private Sub Form_Load()
    optLanguage.Value = True

    ' Load strings.
    Caption = LoadResString(resCaption)
    cmdYes.Caption = LoadResString(resYes)
    cmdNo.Caption = LoadResString(resNo)
    lblSavePrompt.Caption = LoadResString(resPrompt)
    optLanguage.Caption = LoadResString(resLanguageValue)
    fraLanguage.Caption = LoadResString(resLanguage)

    ' Load images.
    cmdYes.Picture = LoadResPicture(respicYes, vbResBitmap)
    cmdNo.Picture = LoadResPicture(respicNo, vbResBitmap)
End Sub
 
One drawback to this method is that you cannot easily change the program's language. You need to change the system's LCID and restart the application.

This method has the advantage that it is (almost) automatic. You don't need to look up the LCID on the computer.

 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated