Name

GetLocale Function

Syntax

GetLocale(  )

Return Value

A Long indicating the current locale ID.

Description

Gets the current locale ID.

Rules at a Glance

  • A locale ID represents a 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.

Programming Tips and Gotchas

  • If you want to temporarily change the locale, 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.

  • GetLocale returns the locale ID currently in use by the script engine.

  • Although you can set the locale using either a decimal, hexadecimal, or string locale ID, the GetLocale function returns only a decimal locale ID value.

  • The default value of the script engine’s locale ID is determined as follows: When the script engine starts up, the host passes it a locale ID. If the host does not do so, the script engine uses the user’s default locale ID. If there is no user, then the script engine uses the system’s default locale ID.

  • Note that the script engine’s locale ID is different from the system locale ID, the user locale ID, and the host application’s locale ID. The GetLocale function reports the locale ID in use by the script engine only.

VBA/VBScript Differences

The GetLocale function is not supported by VBA.

Get VBScript in a Nutshell, 2nd Edition 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.