GetLocale 函數
返回目前範圍設定 ID 值。
GetLocale()
說明
locale 是使用者參考資訊集合,與使用者的語言、國家和文化傳統有關。locale 決定鍵盤配置、字母排序次序和日期、時間、數字與貨幣格式。
傳回值可以是任意一個 32-位 的值,如 地區設定識別碼所示:
下面舉例說明 GetLocale 函數的用法。要使用該代碼,請複製標準HTML 檔案中 <BODY>l 標誌之間的所有內容。
Enter Date in UK format: <input type="text" id="UKDate" size="20"><p>Here's the US equivalent: <input type="text" id="USdate" size="20"><p><input type="button" value="Convert" id="button1"><p>Enter a price in German: <input type="text" id="GermanNumber" size="20"><p>Here's the UK equivalent: <input type="text" id="USNumber" size="20"><p><input type="button" value="Convert" id="button2"><p><script language="vbscript">Dim currentLocale' Get the current localecurrentLocale = GetLocaleSub Button1_nclick Dim original original = SetLocale("en-gb") mydate = CDate(UKDate.value) ' IE always sets the locale to US English so use the ' currentLocale variable to set the locale to US English original = SetLocale(currentLocale) USDate.value = FormatDateTime(mydate,vbShortDate)End SubSub button2_nclick Dim original original = SetLocale("de") myvalue = CCur(GermanNumber.value) original = SetLocale("en-gb") USNumber.value = FormatCurrency(myvalue)End Sub</script>