O'Reilly logo

VBScript in a Nutshell, 2nd Edition by Ron Petrusha, Matt Childs, Paul Lomax

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

SetLocale Function

Syntax

SetLocale(lcid)
lcid

Use: Optional

Data Type: Long or String

A number representing a locale ID.

Return Value

A Long indicating the previous locale ID.

Description

Sets the current locale ID.

Rules at a Glance

  • A locale ID represents language as well as regional conventions. It determines such things as keyboard layout, alphabetic sort order, and date, time, number, and currency formats.

  • Appendix D lists valid locale IDs.

  • If SetLocale is called with no arguments, it resets the script locale back to the host default, which is usually the user default.

  • If lcid is zero or 1024, the locale is set as defined by the user’s locale ID.

  • If lcid is 2048, the local is set as defined by the system’s regional settings.

Programming Tips and Gotchas

  • There is no need to call GetLocale and store its returned value before calling SetLocale, since SetLocale returns the value of the previous locale ID.

  • SetLocale sets the locale ID of the script engine only. It does not affect the system, user, or host/application locale IDs.

VBA/Script Differences

The SetLocale function is not supported by VBA.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required