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

Izjava o odricanju odgovornosti za sadržaj o otpisanom proizvodu u bazi znanja

Ovaj je članak napisan o proizvodu za koji Microsoft više ne pruža podršku. Članak će stoga ostati nepromijenjen i više se neće ažurirati.

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.
Svojstva

ID članka: 232158 - posljednja izmjena: 19. lip 2014. - verzija: 1

Povratne informacije