Microsoft Windows Architecture for Developers Training Kit

Resource Files

A resource file is a useful mechanism for separating localizable information from code. String resources refer to the text that appears in the application's user interface. They include items such as menus , dialog boxes, and informational, alert, and error messages. If an application will be used in a locale other than the one in which it was developed, these resources must be localized.

Storing Strings in Resource Files

When writing Visual Basic code, the LoadResString , LoadResPicture , and LoadResData functions are used in place of references to string literals, pictures, and data. Storing such elements in a resource file offers two benefits:

Example

This example uses the Visual Basic LoadResString function. An index argument is used as an integer specifying the identifier (ID) of the data in the resource file.

strValue = LoadResString(Index)

Категории