title image


Smiley Re: Datumsformat in den Ländereinstellungen auslesen
Das geht z.B. so:



Public Const LOCALE_SLONGDATE = &H20

Public Const LOCALE_SSHORTDATE = &H1F

Public Const WM_SETTINGCHANGE = &H1A

Public Const HWND_BROADCAST = &HFFFF&



Private Declare Function GetLocaleInfo Lib "kernel32" Alias _

"GetLocaleInfoA" (ByVal Locale As Long, ByVal LCType As _

Long, ByVal lpLCData As String, ByVal cchData As Long) As Long



Private Declare Function SetLocaleInfo Lib "kernel32" Alias _

"SetLocaleInfoA" (ByVal Locale As Long, ByVal LCType As _

Long, ByVal lpLCData As String) As Long



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 SendMessage Lib "user32" Alias _

"SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, _

ByVal wParam As Long, lParam As Any) As Long



Private Declare Function GetSystemDefaultLCID Lib "kernel32" _

() As Long



Public Function SetShortDate(Optional sFmt As String = "dd.MM.yyyy")

Dim dwLCID As Long, Res As Long

dwLCID = GetSystemDefaultLCID()

If SetLocaleInfo(dwLCID, LOCALE_SSHORTDATE, sFmt) = 0 Then

MsgBox "Fehler in SetShortDate: SetLocaleInfo"

Else

Res = SendMessage(HWND_BROADCAST, WM_SETTINGCHANGE, 0&, 0&)

End If

End Function



Public Function SetLongDate(Optional sFmt As String = "dddd, d. MMMM yyyy")

Dim dwLCID As Long, Res As Long

dwLCID = GetSystemDefaultLCID()

If SetLocaleInfo(dwLCID, LOCALE_SLONGDATE, sFmt) = 0 Then

MsgBox "Fehler in SetLongDate: SetLocaleInfo"

Else

Res = SendMessage(HWND_BROADCAST, WM_SETTINGCHANGE, 0&, 0&)

End If

End Function



Public Function GetShortDate()

Dim dwLCID As Long, Res As Long, Tmp As String, L As Long

dwLCID = GetSystemDefaultLCID()

Tmp = String(255, 0)

L = Len(Tmp)

Res = GetLocaleInfo(dwLCID, LOCALE_SSHORTDATE, Tmp, L)

GetShortDate = Mid(Tmp, 1, Res - 1)

End Function



Public Function GetLongDate()

Dim dwLCID As Long, Res As Long, Tmp As String, L As Long

dwLCID = GetSystemDefaultLCID()

Tmp = String(255, 0)

L = Len(Tmp)

Res = GetLocaleInfo(dwLCID, LOCALE_SLONGDATE, Tmp, L)

GetShortDate = Mid(Tmp, 1, Res - 1)

End Function



Gruß aus dem Norden
Reinhard


Bitte immer die Access-Version angeben!
DB-Wiki


Wie man Fragen richtig stellt

YaccessAccess-FAQUnd ansonsten: Wikipedia




geschrieben von

Login

E-Mail:
  

Passwort:
  

Beitrag anfügen

Symbol:
 
 
 
 
 
 
 
 
 
 
 
 
 

Überschrift: