HOWTO: Use GetLocale() and SetLocale() in VBScript

ID: Q232158


The information in this article applies to:
  • Microsoft Visual Basic, Scripting Edition, version 5.0


SUMMARY

Visual Basic Scripting Edition (VBScript) version 5.0 supports the functionality of retrieving and changing the current locale settings of your current Web page. The two functions that support this feature are GetLocale() and SetLocale().

GetLocale() returns the current locale on the client machine. SetLocale() sets the locale to the new specified locale

These functions can be used accordingly to localize the date, time, or currency of your Web page.

NOTE: GetLocale() and SetLocale() are not supported in JavaScript.


MORE INFORMATION

The following example demonstrates GetLocale() and SetLocale():


<HTML>

<HEAD>
<SCRIPT language=vbscript>
Dim curLocale

sub window_onload()
	curLocale= GetLocale()

	MsgBox "The current locale is " & GetLocale()
	MsgBox "The current date is " & Date()
	MsgBox "The current time is " & Time()

	Dim MyCurrency
	MyCurrency = FormatCurrency(100) 
	MsgBox "100 U.S. dollars in the U.S is " & MyCurrency
end sub

sub window_onunload()
	SetLocale(curLocale)
end sub

sub changetoFrenchLoc()
	Dim newLocale
	Dim french_lcid

	french_lcid =1036

	'set locale to French
	SetLocale(french_lcid) 

	MsgBox "The current locale is " & GetLocale()
	MsgBox "The current date is " & Date()
	MsgBox "The current time is " & Time()

	Dim MyCurrency
	MyCurrency = FormatCurrency(100 * 6.37546) 
	MsgBox "100 U.S. dollars in France is " & MyCurrency
end sub

</SCRIPT>

</HEAD>

<BODY>
<INPUT TYPE="button" ONCLICK="changetoFrenchLoc()" VALUE="Change to French"></INPUT>
</BODY>

</HTML> 


REFERENCES

For more information regarding Microsoft Scripting Technologies please visit http://msdn.microsoft.com/scripting/.

Additional query words: Locale LCID

Keywords : kbVBScript kbGrpInet kbDSupport
Version : WINDOWS:5.0
Platform : WINDOWS
Issue type : kbhowto


Last Reviewed: July 15, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.