Control Panel > Region >Formate ต้องเป็น Thai (Thailand) Currnet language ต้องเป็น Thai (Thailand)
Option Compare Database
Private Const LOCALE_SSHORTDATE = &H1F
Private Const WM_SETTINGCHANGE = &H1A
Private Const HWND_BROADCAST = &HFFFF&
#If VBA7 Then
Private Declare PtrSafe Function SetLocaleInfo Lib "kernel32" Alias "SetLocaleInfoA" (ByVal Locale As Long, ByVal LCType As Long, ByVal lpLCData As String) As Boolean
Private Declare PtrSafe Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Declare PtrSafe Function GetSystemDefaultLCID Lib "kernel32" () As Long
#Else
Private Declare Function SetLocaleInfo Lib "kernel32" Alias "SetLocaleInfoA" (ByVal Locale As Long, ByVal LCType As Long, ByVal lpLCData As String) As Boolean
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Declare Function GetSystemDefaultLCID Lib "kernel32" () As Long
#End If
Function setdate() 'ใช้เปลี่ยนรูปแบบวันที่
Dim dwLCID As Long
dwLCID = GetSystemDefaultLCID()
If SetLocaleInfo(dwLCID, LOCALE_SSHORTDATE, "dd/MM/yyyy") = False Then
MsgBox "รูปแบบวันที่ไม่ใช่ dd/MM/yyyy", vbCritical, "Error"
End If
PostMessage HWND_BROADCAST, WM_SETTINGCHANGE, 0, 0
End Function
กระทู้ถามว่าไงเนี๊ย