Any idea How to prevent from different date/time format on different pc
I've heard that I should create my own system time function in VBA which will not depend from the local pc system date/time setting
Regards
This might help you , at the start of you application change the system date format to you desire on by using this code
Instructions
Simply copy and pase the function into your programe and run the function by typing
SetDateTime at load event or your desired event.
if you want to change your format to any other type just change
"dd-MMM-yyyy" as your desired format. - 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-MMM-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****************
Source http://www.dreamincode.net/code/snippet1364.htm 3 4642
let's say that I've used this format :
dd.mm.yyyy
in some certain control
and the local date format settings is:
yyyy-mm-dd
then if I use
format(ctl,"ww") result is false
or if i've write in table date in one format all further action can be confused after somehow the local date settings had been changed or mdb would be used on other computer
any idea how to solve this problem
I need somehow to tell to VB that I use some certain date format instead the local date/time settings, so vb to ignore the local date/time format
This might help you , at the start of you application change the system date format to you desire on by using this code
Instructions
Simply copy and pase the function into your programe and run the function by typing
SetDateTime at load event or your desired event.
if you want to change your format to any other type just change
"dd-MMM-yyyy" as your desired format. - 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-MMM-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****************
Source http://www.dreamincode.net/code/snippet1364.htm
thanks... i trie'd it and it works
But, i'm not sure if it's the best solution that I change the local date settings..
it should be some way that VB can ignore or convert date format while the application is running..
I found some code that is doing some conversion but doesn't work as follow:
Private Declare Function GetTimeZoneInformation Lib "kernel32" _
(lpTimeZoneInformation As TIME_ZONE_INFORMATION) As Long
Public Sub ConvertSysDate()
Dim dwLCID As Long
'
dwLCID = GetSystemDefaultLCID()
'
If SetLocaleInfo(dwLCID, LOCALE_SSHORTDATE, "MM/dd/yyyy") = _
False Then
Exit Sub
End If
PostMessage HWND_BROADCAST, WM_SETTINGCHANGE, 0, 0
End Sub
Call ConvertSysDate
can anyone fix the code?
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Brian |
last post by:
I have 4 sites sharing an account on a server that is in the US Eastern
time zone. 3 of those sites are for businesses/persons who live in the
same time zone, but one is for a restaurant in the US...
|
by: Thomas Scheiderich |
last post by:
I have the following page as test.aspx:
***************************************************
<html>
<head>
<title>Hello and Welcome Page</title>
</head>
<body>
<center>
<%
Dim CurrentDate As...
|
by: Andrew Poulos |
last post by:
I'm updating a db in which I have a column of Date/Time data type. The
regional settings here for short date are:
day / month / full year
eg. 28/4/2005
It's easy enough for me to build a string...
|
by: Assimalyst |
last post by:
Hi,
I have a working script that converts a dd/mm/yyyy text box date entry
to yyyy/mm/dd and compares it to the current date, giving an error
through an asp.net custom validator, it is as...
|
by: mr.nimz |
last post by:
hello,
this is antenio. recently i've come to a problem. i got a way through
it, somehow, still it left me in a curious state, so i'm posting it
here, if i can get an answer from some techy,
...
|
by: Darin |
last post by:
I have an applicatoin that works 100% perfect when running on a machine
setup for English (United States), but when I change it to Spanish
(Mexico), the dates start giving me fits.
THe reason is...
|
by: ARC |
last post by:
Hello all,
General question for back-end database that has numerous date fields where
the database will be used in regions that put the month first, and regions
that do not.
Should I save a...
|
by: Wiretwisterz |
last post by:
I am using Microsoft Office XP and I have developed an Access database that is used to schedule conference and training rooms within buildings.
I have one main form named "Events" that is used to...
|
by: Madhu Harchandani |
last post by:
Hello
i am working in a project in which i am using xnat technology in that data is entered through xml files only i need to enter 1000 records .so it is very cumbersome to create...
|
by: Wayne |
last post by:
I'm building a bookings database for trucks that among other things
captures the TruckName, LoadDate, LoadTime, UnloadDate and UnloadTime.
Is there a simple way to prevent double bookings for any...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |