snasui.com ยินดีต้อนรับ ยินดีต้อนรับสู่กระดานถามตอบ Excel and VBA และอื่น ๆ ที่เป็นมิตรกับทุกท่าน มีไฟล์แนบมหาศาล ช่วยให้ท่านค้นหาและติดตามศึกษาได้โดยง่าย สมาชิกท่านใดที่ยังไม่ได้ระบุ Version ของ Excel ที่ใช้งานจริง สามารถทำตาม Link นี้เพื่อจะได้รับคำตอบที่ตรงกับ Version ของท่านครับ ระบุ Version ของ Excel
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
ผมต้องเช็คค่า System Locale ของเครื่องคอมพิวเตอร์ที่ใช้งานอยู่ตอนนี้ว่าตั้งค่าเป็นประเทศอะไร โดยได้ทดลองตั้งเป็น English (USA) แต่พอรัน Code กลับบอกว่าเป็น Thai (Thailand)
จะต้องปรับแก้อย่างไรครับ
You do not have the required permissions to view the files attached to this post.
#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