Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old September 11th, 2004, 07:28 PM
joshid joshid is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 1 joshid User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #2  
Old July 5th, 2007, 07:02 AM
square1827 square1827 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2007
Posts: 1 square1827 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 m 36 sec
Reputation Power: 0
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****************

Reply With Quote
  #3  
Old October 8th, 2007, 05:27 AM
shanshivakumar shanshivakumar is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2007
Posts: 3 shanshivakumar User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 49 m 48 sec
Reputation Power: 0
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

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > system date format change in vb6


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump



 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT