Change Date Format +vb.net

Monday, May 12, 2008

Module mdl_ShortDateFormat


Private Const DATE_SHORTDATE = &H1
Public Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
Public Declare Function EnumDateFormats Lib "KERNEL32" Alias "EnumDateFormatsA" (ByVal lpDateFmtEnumProc As Integer, ByVal Locale As Integer, ByVal dwFlags As Integer) As Integer
Public Declare Function GetSystemDefaultLCID Lib "kernel32" Alias "GetSystemDefaultLCID" () As Integer
Public Declare Function SetLocaleInfo Lib "kernel32" Alias "SetLocaleInfoA" (ByVal Locale As Integer, ByVal LCType As Integer, ByVal lpLCData As String) As Integer
Public Function SetShortDateFormat()
Dim xCID As Long
Dim xChangedFormat As String
Try
xCID = GetSystemDefaultLCID()
Catch ex As Exception
End Try
xChangedFormat = "dd/MM/yyyy"
Try
Call SetLocaleInfo(xCID, LOCALE_SSHORTDATE, xChangedFormat)
Catch ex As Exception
End Try

Try
Call PostMessage(HWND_BROADCAST, WM_SETTINGCHANGE, 0&, 0&)
Catch ex As Exception
End Try

Try
Call EnumDateFormats(0, xCID, DATE_SHORTDATE)
Catch ex As Exception
End Try

End Function
End Module

0 comments

Post a Comment