|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
system date format change in vb6
hello,
anyone have experience how to change the country definitions with vb6? my problem is : living in france the standard date format is :dd,mm,yyyy. but I have some applications where the date MUST be entered in the forme of: yyyy.mm.dd I would like to change at the beginning of the program the country specification to yyyy.mm.dd and at the end turn back into dd,mm,yyyy. thank you for helping joshid |
|
#2
|
|||
|
|||
|
Change date format in Regional Setting of Control Panel through VB6
attached is vb6 module that changes the date and time format in regioanl settings to dd,mm,yyyy and HH:mm:ss
you can use it for the format you want. hope this helps regards *******************start of module********** Option Explicit Private Const LOCALE_SDATE = &H1F Private Const LOCALE_STIMEFORMAT = &H1003 Private Const WM_SETTINGCHANGE = &H1A Private Const HWND_BROADCAST = &HFFFF& 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 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 Public Function SetDateTime() As Boolean Dim dwLCID As Long dwLCID = GetSystemDefaultLCID() If SetLocaleInfo(dwLCID, LOCALE_SDATE, "dd,MM,yyyy") = False Then SetDateTime = False Exit Function End If If SetLocaleInfo(dwLCID, LOCALE_STIMEFORMAT, "HH:mm:ss") = False Then SetDateTime = False Exit Function End If PostMessage HWND_BROADCAST, WM_SETTINGCHANGE, 0, 0 SetDateTime = True End Function ***************end of module**************** |
|
#3
|
|||
|
|||
|
get & set system date format
Form_Load()
'--------------- GET Current sysdate format ---------------------------------------- '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 GetUserDefaultLCID Lib "kernel32" () As Long 'Private Const LOCALE_SSHORTDATE = &H1F 'Dim strResult As String 'Dim strInfo As String * 10 'lngIdentifier = GetUserDefaultLCID() 'lngResult = GetLocaleInfo(lngIdentifier, LOCALE_SSHORTDATE, strInfo, 10) 'strResult = "Short Date String = " & strInfo & vbLf 'MsgBox Replace(strResult, Chr(0), "") 'eg m/d/yy '--------------- GET Current sysdate format ---------------------------------------- '--------------- GET Current sysdate format to indian date formate dd/mm/yyyyy -------------------- Dim xCID As Long Dim xChangedFormat As String xCID = GetSystemDefaultLCID() xChangedFormat = "dd/MM/yyyy" If xChangedFormat <> "" Then Call SetLocaleInfo(xCID, LOCALE_SSHORTDATE, xChangedFormat) Call PostMessage(HWND_BROADCAST, WM_SETTINGCHANGE, 0&, ByVal 0&) Call EnumDateFormats(AddressOf theEnumDates, xCID, DATE_SHORTDATE) End If '--------------- GET Current sysdate format to indian date formate dd/mm/yyyyy -------------------- module Name --> set date format ------------------------------------------------- Option Explicit Public Const LOCALE_SLANGUAGE As Long = &H2 Public Const LOCALE_SSHORTDATE As Long = &H1F Public Const DATE_LONGDATE As Long = &H2 Public Const DATE_SHORTDATE As Long = &H1 Public Const HWND_BROADCAST As Long = &HFFFF& Public Const WM_SETTINGCHANGE As Long = &H1A Public Declare Function PostMessage Lib "user32" _ Alias "PostMessageA" _ (ByVal hwnd As Long, _ ByVal wMsg As Long, _ ByVal wParam As Long, _ lParam As Any) As Long Public Declare Function EnumDateFormats Lib "kernel32" _ Alias "EnumDateFormatsA" _ (ByVal lpDateFmtEnumProc As Long, _ ByVal Locale As Long, _ ByVal dwFlags As Long) As Long Public Declare Sub CopyMemory Lib "kernel32" _ Alias "RtlMoveMemory" _ (Destination As Any, _ Source As Any, _ ByVal Length As Long) Public Declare Function GetSystemDefaultLCID Lib "kernel32" () As Long Public 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 Public Declare Function SetLocaleInfo Lib "kernel32" _ Alias "SetLocaleInfoA" _ (ByVal Locale As Long, _ ByVal LCType As Long, _ ByVal lpLCData As String) As Long Public Function fGetUserLocaleInfo(ByVal lLocaleID As Long, _ ByVal lLCType As Long) As String Dim sReturn As String Dim lReturn As Long lReturn = GetLocaleInfo(lLocaleID, lLCType, sReturn, Len(sReturn)) If lReturn Then sReturn = Space$(lReturn) If lReturn Then fGetUserLocaleInfo = Left$(sReturn, lReturn - 1) End If End If End Function Public Function theEnumDates(lDateFormatString As Long) As Long theEnumDates = 1 End Function Private Function GetStrFromPointer(sString As Long) As String Dim lPos As Long Dim sBuffer As String sBuffer = Space$(128) Call CopyMemory(ByVal sBuffer, sString, ByVal Len(sBuffer)) lPos = InStr(sBuffer, Chr$(0)) If lPos Then GetStrFromPointer = Left$(sBuffer, lPos - 1) End If End Function |
![]() |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > system date format change in vb6 |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|