สอบถาม Code VB เช็คค่า System Locale
Posted: Sat Oct 11, 2025 10:13 am
จากไฟล์ที่แนบมา
ผมต้องเช็คค่า System Locale ของเครื่องคอมพิวเตอร์ที่ใช้งานอยู่ตอนนี้ว่าตั้งค่าเป็นประเทศอะไร โดยได้ทดลองตั้งเป็น English (USA) แต่พอรัน Code กลับบอกว่าเป็น Thai (Thailand)
จะต้องปรับแก้อย่างไรครับ
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
จะต้องปรับแก้อย่างไรครับ