SetLocale - VBScript


The SetLocale command in VB Script allows you to set the current locale of your script. This is useful for internationalizing your scripts by adapting them to specific regional or language settings.




  • LocaleID: The locale identifier to set. This is a string that represents the language and region code (e.g., “en-US” for English-United States).




Simple Example:


This sets the current locale to English-United States.

Complex Example:

Dim objDate
Set objDate = CreateObject("Scripting.FileSystemObject").GetFile("file.txt")

Wscript.Echo "File Date: " & objDate.DateLastModified

This script gets the last modified date of a file and displays it in the current locale format. It uses the SetLocale command to ensure that the date format is appropriate for the user’s region.

Common Issues

  • Incorrect LocaleID: If you specify an invalid locale identifier, an error will occur.
  • Unsupported Locale: If the current system does not support the specified locale, an error will occur.


The SetLocale command can be integrated with other VB Script commands to provide localized output. For example, you could use the FormatNumber function to format numbers in the current locale format.

  • GetLocale: Retrieves the current locale identifier.
  • FormatNumber: Formats a number according to the current locale settings.
  • FormatCurrency: Formats a currency value according to the current locale settings.
  • FormatDate: Formats a date according to the current locale settings.
  • FormatTime: Formats a time according to the current locale settings.