Change Date Format of the system
Change Date Format of the system
API Declarations
Public Const LOCALE_USER_DEFAULT As Long = &H400
Public Declare Function GetLocaleInfo Lib "kernel32" _
Alias "GetLocaleInfoA" (ByVal lLocale As Long, _
ByVal lLocaleType As Long, ByVal sLCData As String, _
ByVal lBufferLength As Long) As Long
Public Declare Function SetLocaleInfo Lib "kernel32" _
Alias "SetLocaleInfoA" (ByVal Locale As Long, _
ByVal LCType As Long, ByVal lpLCData As String) As Long
Rate Change Date Format of the system
(1(1 Vote))
'i have used for short date format similarly it can be used for long
'date format
Dim shortDateFormat As String
Dim lBuffSize As String
Dim sBuffer As String
Dim lRetGet As Long
Dim lRetSet As Long
lBuffSize = 256
sBuffer = String$(lBuffSize, vbNullChar)
'get the date information in buffer
lRetGet = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SSHORTDATE, sBuffer, lBuffSize)
If lRetGet > 0 Then
shortDateFormat = Left$(sBuffer, lRetGet - 1)
'this is the existing format of machine
End If
'to change the format if doesn't matches ur format
'MM should be used in capital for monyhs,small m are for minutes
If LCase(shortDateFormat) <> "dd/mm/yyyy" Then
lRetSet = SetLocaleInfo(LOCALE_USER_DEFAULT,_ LOCALE_SSHORTDATE, "dd/MM/yyyy")
'on sucess lretset have value greater than 0
If lRetSet <= 0 Then
msgbox "date format not changed
End If
End If
Change Date Format of the system Comments
No comments yet — be the first to post one!
Post a Comment