Find Code:
All Words
Any of the Words
Exact Phrase
Home
:
Code
:
Forums
:
Submit
:
Mailing List
:
About
:
Contact
Code
All
VB.NET
ASP.NET
C#
VB Classic
ASP Classic
Snippets
Popular
Resources
Submit Code
Forums
Articles
Tips
Links
Books
Contest
Link to us
This snippet shall check the format of the date an...
Author:
Bhagyesh Trivedi
E-mail:
Click to e-mail author
Submitted:
3/19/2002
Version:
VB6
Compatibility:
VB6
Category:
Windows API
Views:
15937
This snippet shall check the format of the date and change it if not the same. :-) Use it if u want the format to be dd/MM/yyyy
Declarations:
Private Declare Function GetSystemDefaultLCID Lib "kernel32" () As Long Private Const LOCALE_SSHORTDATE = &H1F ' short date format string 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 SetLocaleInfo Lib "kernel32" Alias "SetLocaleInfoA" (ByVal Locale As Long, ByVal LCType As Long, ByVal lpLCData As String) As Long
Code:
'Call this function to check the date format and change it if necessary Private Sub Command1_Click() Dim sReturn As String Dim r As Long Dim LCID As Long LCID = GetSystemDefaultLCID() r = GetLocaleInfo(LCID, LOCALE_SSHORTDATE, sReturn, Len(sReturn)) If r Then 'pad the buffer with spaces to create the size of memory buffer sReturn = Space$(r) 'and call again passing the buffer r = GetLocaleInfo(LCID, LOCALE_SSHORTDATE, sReturn, Len(sReturn)) 'if successful (r > 0) If r Then 'r holds the size of the string 'including the terminating null If Left$(sReturn, r - 1) <> "dd/MM/yyyy" Then Call SetLocaleInfo(LCID, LOCALE_SSHORTDATE, "dd/MM/yyyy") End If End If End If End Sub
Home
|
Forums
|
Submit
|
Books
|
Mailing List
|
Advertising
|
About
|
Contact
© 2024 A1VBCode. All rights reserved.
Legal disclaimer & terms of use
Privacy statement