Article ID: 232158 - Last Review: August 8, 2007 - Revision: 1.2

How To Use GetLocale() and SetLocale() in VBScript

This article was previously published under Q232158
Expand all | Collapse all

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://msdn2.microsoft.com/en-us/library/ms950396.aspx (http://msdn2.microsoft.com/en-us/library/ms950396.aspx) .

APPLIES TO
  • Microsoft Visual Basic, Scripting Edition 5.0
Keywords: 
kbhowto KB232158
Retired KB ArticleRetired KB Content Disclaimer
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.
 

Article Translations