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 April 14th, 2005, 05:15 AM
sabah sabah is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 36 sabah User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 8 m 13 sec
Reputation Power: 4
big date problem

i have almost finished a program using access (french version) after i discovered that everytime i enter the date through the form it switches the day and the month in the table i know the problem is because the french date and english date are the opposit
but i dont understand which is english and which is french and what can i do
big confusion
anyone can help

Reply With Quote
  #2  
Old April 14th, 2005, 08:21 AM
Darius Darius is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 108 Darius User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 16 m 54 sec
Reputation Power: 5
Quote:
Originally Posted by sabah
i have almost finished a program using access (french version) after i discovered that everytime i enter the date through the form it switches the day and the month in the table i know the problem is because the french date and english date are the opposit
but i dont understand which is english and which is french and what can i do
big confusion
anyone can help

You have two options
1- (the best), detect the regional settings configuration and act accordingly
2- change the regional settings configuration to your own (not a good idea, other programs may use the other format).

Code:
 Dim LCID As Long, iRet As Long, lpLCDataVar As String, Symbol As String
Dim iRet2 As Long, pos As Integer
Public blnMDSettingsChanged As Boolean

Private Declare Function GetUserDefaultLCID Lib "kernel32" () As Long
Private Declare Function GetSystemDefaultLCID Lib "kernel32" () As Long
Private Declare Function GetThreadLocale 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
'tablas factor Z
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, _
lParam As Any) As Long
 
Private Const HWND_BROADCAST As Long = &HFFFF&
Private Const WM_SETTINGCHANGE As Long = &H1A
Const LOCALE_SDECIMAL As Long = &HE		'decimal separator
Const LOCALE_STHOUSAND = &HF 'thousand separator
Const LOCALE_SSHORTDATE = &H1F 'short date
Const LOCALE_SCURRENCY = &H14 'currency symbol
Const LOCALE_SMONDECIMALSEP = &H16 ' 'decimal separator for currency
Const LOCALE_SMONTHOUSANDSEP = &H17 'thousand separator for currency
Const old_LOCALE_SDECIMAL As String
Const old_LOCALE_STHOUSAND As String
Const old_LOCALE_SSHORTDATE As String
Const old_LOCALE_SMONTHOUSANDSEP As String
Const old_LOCALE_SMONDECIMALSEP As String
Const old_LOCALE_SCURRENCY As String
 
Function IsDateFormatRight(CHANGE_ENABLED as boolean,optional DATEFORMAT as string ="dd/MM/yyyy") as boolean
' read short date
	LCID = GetUserDefaultLCID()
	iRet = GetLocaleInfo(LCID, LOCALE_SSHORTDATE, lpLCDataVar, 0)
	Symbol = String$(iRet, 0)
	iRet2 = GetLocaleInfo(LCID, LOCALE_SSHORTDATE, Symbol, iRet)
	pos = InStr(Symbol, Chr$(0))
	If pos > 0 Then
		Symbol = Left$(Symbol, pos - 1)
	End If
 
	If Symbol <> DATEFORMAT and CHANGE_ENABLED Then
	 pos = MsgBox("The date's format doesn't match (" & Symbol & ") and could produce system errors." & Chr(13) & "To work properly, is recommended to change the regional options to " & DATEFORMAT & Chr(13) & "Do you acept to make the change?", vbQuestion + vbYesNo, "Configuration")
	 If pos = vbYes Then
		'change thousand separator
		 blnMDSettingsChanged = True
		 old_LOCALE_SSHORTDATE = Symbol
		 LCID = GetUserDefaultLCID()
		 Call SetLocaleInfo(LCID, LOCALE_SSHORTDATE, DATEFORMAT)
		 Call PostMessage(HWND_BROADCAST, WM_SETTINGCHANGE, 0&, ByVal 0&)
	 End If
	 IsDateFormatRight= true
	else
	 IsDateFormatRight= Symbol <> DATEFORMAT
	End If
End Function
 
Public Sub restoreDateSettings()
	If old_LOCALE_SSHORTDATE <> vbNullString Then
	' restore short date
		LCID = GetUserDefaultLCID()
		Call SetLocaleInfo(LCID, LOCALE_SSHORTDATE, old_LOCALE_SSHORTDATE)
		Call PostMessage(HWND_BROADCAST, WM_SETTINGCHANGE, 0&, ByVal 0&)
	End If
End Sub

I hope nothing is missing.

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > big date problem


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


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





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