EXCEL TOOLS
Excel Add-ins ที่พัฒนาโดยคุณสันติพงศ์ ณสุย (MVP Excel 2010-2020) ด้วยภาษา C# เพื่อแก้ไขปัญหาไฟล์ใหญ่ คำนวณนาน ทำงานช้า จัดการข้อมูลต่าง ๆ ที่ทำงานประจำวันได้อย่างสะดวกรวดเร็ว สนใจคลิกไปดูได้ที่นี่ครับ => Excel Tools
Excel Add-ins ที่พัฒนาโดยคุณสันติพงศ์ ณสุย (MVP Excel 2010-2020) ด้วยภาษา C# เพื่อแก้ไขปัญหาไฟล์ใหญ่ คำนวณนาน ทำงานช้า จัดการข้อมูลต่าง ๆ ที่ทำงานประจำวันได้อย่างสะดวกรวดเร็ว สนใจคลิกไปดูได้ที่นี่ครับ => Excel Tools
[code]
และปิดด้วย [/code]
ตัวอย่างเช่น [code]dim r as range[/code]
เพื่อให้แตกต่างจากข้อความทั่วไป สะดวกในการอ่านและทดสอบ (คลิกเพื่อดูตัวอย่าง)Code: Select all
Sub CheckSystemLocale()
Dim lang_code As Long
' Get the LCID of the user interface language
lang_code = Application.LanguageSettings.LanguageID(msoLanguageIDUI)
' Display the LCID
MsgBox "The system UI locale LCID is: " & lang_code
' You can then use this LCID in conditional statements
If lang_code = 1033 Then ' 1033 is English (US)
MsgBox "The system locale is English (US)."
ElseIf lang_code = 1054 Then ' 1054 is Thai (Thailand)
MsgBox "The system locale is Thai (Thailand)."
Else
MsgBox "The system locale is not English (US) or Thai (Thailand)."
End If
End Sub
Application.LanguageSettings.LanguageID(msoLanguageIDUI)
จะคืนค่า LCID ของ User Interface (UI) ของ Excel ไม่ใช่ System Locale ของ Windows โดยตรง ดังนั้นแม้จะตั้งค่า Windows เป็น English (USA) แต่ถ้า Excel ยังใช้ UI ภาษาไทย ก็จะได้ค่า LCID = 1054 (Thai)Code: Select all
#If VBA7 Then
Private Declare PtrSafe Function GetSystemDefaultLCID Lib "kernel32" () As Long
#Else
Private Declare Function GetSystemDefaultLCID Lib "kernel32" () As Long
#End If
Sub CheckSystemLocale()
Dim sysLCID As Long
sysLCID = GetSystemDefaultLCID()
MsgBox "System Locale LCID is: " & sysLCID
Select Case sysLCID
Case 1033
MsgBox "System Locale is English (US)"
Case 1054
MsgBox "System Locale is Thai (Thailand)"
Case Else
MsgBox "System Locale is not English (US) or Thai (Thailand)"
End Select
End Sub