LoadResString Function

Syntax

LoadResString(resID)

resID

Use: Required

Data Type: Variant

A numeric value specifying the resource ID of the string to load.

Return Value

A String.

Description

Retrieves a string from a resource file (.RES) that can be assigned to a string variable or to the string property of a control, such as a label caption.

Rules at a Glance

  • The strings to be retrieved by LoadResString must be included in a resource (.RES ) file. Each must be assigned a unique identifier, which is typically represented by a numeric constant.

  • The identifier 1 is reserved for use by the application icon.

Programming Tips and Gotchas

  • LoadResString is part of the VB Runtime Library and isn't available in VBA applications.

  • Using resource strings is the ideal way to internationalize your application, as the following example demonstrates.

  • Unlike the LoadResData function, LoadResString returns an ANSI string that can be directly assigned to a form or control property.

  • VB6 includes an add-in Resource Editor; see the sidebar in the previous entry for more information.

Example

This example demonstrates how to use LoadResString in conjunction with the GetLocaleInfo API call to internationalize a VB application. This example assumes that a resource file containing menu caption strings in various languages has been created and added to the project. A Form_Load event could call the getLanguage function, which in turns calls the relevant API function to return the current language of the ...

Get VB & VBA in a Nutshell: The Language now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.