P
PeterEvans
I want to set an expiry date which I am storing in the registry. This
is all working well.
The problem is when someone installs the software, then changes their
location (Australia dd/mm/yyyy to USA mm/dd/yyyy). On startup the
software retrieves the stored date and the days to go are wrong.
I have a work around that works out the daystogo based on hard-coding
the date into code and that is OK for the beta.
Sub workAround()
Dim dateexpire As Date
dateexpire = CDate("April 1, 2009")
Debug.Print System.LanguageDesignation & " dateexpire=" &
dateexpire & " daystogo=" & DateDiff("d", Date, dateexpire)
End Sub
Output in the immediate window
workAround
English (U.S.) dateexpire=4/1/2009 daystogo=45
(change region)
workAround
English (Australia) dateexpire=1/04/2009 daystogo=45
I had tried to use the same strategy to save the expirary date
using
dateexpire = CDate("April 1, 2009")
then saving this and then reading it on startup it does not work as
the date and the month is around the wrong way.
Does anyone have any idea how I can have a general solution that works
in all location and even if people move location. The code is below
and you can download a small word document with the code in it from
http://www.baker-evans.com/community/mod/forum/discuss.php?d=167#p196
Any help gratefully received,
PeterEvans
Sub setExpire()
Dim dateInstalled As Date
Dim dateexpire As Date
dateexpire = CDate("April 1, 2009")
dateInstalled = Date
daystogo = DateDiff("d", Date, dateexpire)
SaveSetting appname:="test", Section:="test", Key:="dateExpire",
setting:=dateexpire
SaveSetting appname:="test", Section:="test",
Key:="dateinstalled", setting:=dateInstalled
Debug.Print System.LanguageDesignation & " date=" & Date & "
DateInstalled=" & dateInstalled & " dateexpire=" & dateexpire & "
daystogo=" & daystogo
End Sub
Sub readExpire()
Dim dateInstalled As Date
Dim dateexpire As Date
dateexpire = GetSetting(appname:="test", Section:="test",
Key:="dateExpire")
dateInstalled = GetSetting(appname:="test", Section:="test",
Key:="dateinstalled")
daystogo = DateDiff("d", Date, dateexpire)
Debug.Print System.LanguageDesignation & " date=" & Date & "
DateInstalled=" & dateInstalled & " dateexpire=" & dateexpire & "
daystogo=" & daystogo
End Sub
is all working well.
The problem is when someone installs the software, then changes their
location (Australia dd/mm/yyyy to USA mm/dd/yyyy). On startup the
software retrieves the stored date and the days to go are wrong.
I have a work around that works out the daystogo based on hard-coding
the date into code and that is OK for the beta.
Sub workAround()
Dim dateexpire As Date
dateexpire = CDate("April 1, 2009")
Debug.Print System.LanguageDesignation & " dateexpire=" &
dateexpire & " daystogo=" & DateDiff("d", Date, dateexpire)
End Sub
Output in the immediate window
workAround
English (U.S.) dateexpire=4/1/2009 daystogo=45
(change region)
workAround
English (Australia) dateexpire=1/04/2009 daystogo=45
I had tried to use the same strategy to save the expirary date
using
dateexpire = CDate("April 1, 2009")
then saving this and then reading it on startup it does not work as
the date and the month is around the wrong way.
Does anyone have any idea how I can have a general solution that works
in all location and even if people move location. The code is below
and you can download a small word document with the code in it from
http://www.baker-evans.com/community/mod/forum/discuss.php?d=167#p196
Any help gratefully received,
PeterEvans
Sub setExpire()
Dim dateInstalled As Date
Dim dateexpire As Date
dateexpire = CDate("April 1, 2009")
dateInstalled = Date
daystogo = DateDiff("d", Date, dateexpire)
SaveSetting appname:="test", Section:="test", Key:="dateExpire",
setting:=dateexpire
SaveSetting appname:="test", Section:="test",
Key:="dateinstalled", setting:=dateInstalled
Debug.Print System.LanguageDesignation & " date=" & Date & "
DateInstalled=" & dateInstalled & " dateexpire=" & dateexpire & "
daystogo=" & daystogo
End Sub
Sub readExpire()
Dim dateInstalled As Date
Dim dateexpire As Date
dateexpire = GetSetting(appname:="test", Section:="test",
Key:="dateExpire")
dateInstalled = GetSetting(appname:="test", Section:="test",
Key:="dateinstalled")
daystogo = DateDiff("d", Date, dateexpire)
Debug.Print System.LanguageDesignation & " date=" & Date & "
DateInstalled=" & dateInstalled & " dateexpire=" & dateexpire & "
daystogo=" & daystogo
End Sub