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

Exclusion de responsabilité du contenu obsolète de la base de connaissances

Cet article a été rédigé sur les produits pour lesquels Microsoft n’offre plus aucune prise en charge. Par conséquent, cet article est proposé « en l’état » et ne sera plus mis à jour.

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.
Propriétés

ID d'article : 232158 - Dernière mise à jour : 19 juin 2014 - Révision : 1

Commentaires