I think you pretty much have it.
> Q1: The question (finally) is *what* file of resources
> do I create, and *where*, that can handle all the
> "run-time" strings I need to define
Just as you did. Open the Project menu, select Add New Item, pick the Resources File template, enter a name liks ErrorMessages.resx, and click OK. The file should appear in the Solution Explorer. If it's not open already, double-click it to open it and add resources.
Next create a localized version of the file. You can use Project\Add New Item again but you'll want to add exactly the same resources as in the other version so you might just want to copy that one. Select that file in Solution Explorer, press Ctrl-C and Ctrl-V. Right-click on the new file, select Rename, and give it the same name as the other file but with the localization ID as in ErrorMessages.fr-FR.resx. Double-click that file and change the resources to use the French values. Leave the resource names alone so they match the names in the default file ErrorMessages.resx.
Just because the files are part of hte solution, Visual Basic automatically generates code to manage them so you can do this following:
Here the name "WindowsApplication1.ErrorMessages" is the project's root namespace (by default, also the name of the project) followed by the resource file's name without any extension information. The program will automatically pick between ErrorMessages.resx and ErrorMessages.fr-FR.resx at run time.
The name "MsgNotFound" is the name of a string resource in the files.
You can also do it this longer way:
Dim resource_manager As New _
ResourceManager("WindowsApplication1.ErrorMessages ", _
> At first I assumed that these custom "run-time" strings should be
> added to either the "French" or "Default" Localization Resource files
> defined for my form. However, when I tried to add a string to either
> file, VS squawks loudly, warning me that I probably shouldn't try.
Don't do it. The Form Designer automatically generates those files so it will probably overwrite any changes that you make.
You *could* use the Form Designer to hide values in labels and picture boxes on the form and set their Visible properties to False. Then you could do stuff like:
> Instead, I created a new "Resource File" named
> "Resource.fr.resx" using "Add Item" under the
> "Project" menu. And, it lets me add all the "french"
> string resources I want. The only problem
> is that it shows up at the highest level under
> "WindowsApplication1" on the Solution Explorer.
> I was expecting it to show up under "My Project"
> which is where the "default" (English) string resources are defined.
That's where Visual Studio puts it.
> Q2: Because it doesn't show up there, how do I know
> that it will be automatically selected instead of
> "Resources.resx" in France or when I access any
> ResourceManager string in Example1, Example2, or Example 3?
IntelliSense will see it in My.Resources. You can't really *know* that it will get the right localized version until you try it. Be sure to use an exactly matching file name (plus the locale identifier). Also be sure the resource strings have exactly the same names.
> Q3: Or, should I have gone ahead and edited the
> "Localization Resource" files that VS strongly
> suggested I not edit?
Let me know if it's still giving you trouble. It is a fairly confusing topic.
Author of "Visual Basic 2005 Programmer's Reference"