|
-
Oct 3rd, 2006, 05:21 PM
#1
Thread Starter
Hyperactive Member
Offset Internal Calendar by Plus/Minus 2 Days???
I have an application that converts dates between the two calendars in VB like this:
VB Code:
Dim dt as Date
dt = Date
Calendar = vbCalGreg
Msgbox dt
Calendar = vbCalHijri
Msgbox dt
This works fine, however the hijri calendar is not fixed like the gregorian calendar depending on moon sightings.
What I would like to do is find a way to offset the result returned by windows for the hijri calendar through either api calls or a setting in the registry.
Using Dateadd function is not a solution as the application uses the results in constructing a calendar. The solution must involve either api call or setting in the registry.
Any help would be appreciated. Thank you in advance.
-
Oct 3rd, 2006, 06:34 PM
#2
Thread Starter
Hyperactive Member
Re: Offset Internal Calendar by Plus/Minus 2 Days???
Ok I found this on MSDN, however when I change the registry value it doesn't change anything. I tried rebooting and it still is not working.
http://www.microsoft.com/middleeast/...cCalendar.aspx
=============================
You can adjust the Hijri Calendar from your registry, by modifying the AddHijriDate key value at
HKEY_CURRENT_USER\Control Panel\International\ and setting it to one of the following values:
Value
Meaning
AddHijriDate-2 Subtract two days.
AddHijriDate Subtract one day.
(blank) No adjustment is necessary. (If the date has not been adjusted, this entry does not appear in the registry. If the date has been adjusted and then restored to its original value, this entry appears in the registry with no value.)
AddHijriDate+1 Add one day.
AddHijriDate+2 Add two days.
-
Nov 3rd, 2006, 12:27 PM
#3
Thread Starter
Hyperactive Member
Re: Offset Internal Calendar by Plus/Minus 2 Days???
I still have not found a solution for this problem, so I will rephrase the question. Let us say I want the Date function of VB to return a date that is plus/minus the date but the same weekday.
For example today is Friday November 3rd 2006
I want the function to return Friday November 1st 2006.
The reason is that I build a picturebox calendar with the dates but for the Hijri calendar can be offset plus/minus 2 days.
Any ideas? Thank you for any assistance.
-
Nov 3rd, 2006, 12:39 PM
#4
Re: Offset Internal Calendar by Plus/Minus 2 Days???
You can add or remove two days with the DateAdd() function:
VB Code:
Debug.Print DateAdd("d", 2, dt)
Debug.Print DateAdd("d", -2, dt)
But to be the same weekday... I can't see how's that possible
-
Nov 3rd, 2006, 02:58 PM
#5
Thread Starter
Hyperactive Member
Re: Offset Internal Calendar by Plus/Minus 2 Days???
Thank you gavio but using Dateadd function is not a solution as the application uses the results in constructing the picturebox calendar. The solution must involve either an api call or setting in the registry. Unless there is another solution?
-
Nov 3rd, 2006, 11:39 PM
#6
Re: Offset Internal Calendar by Plus/Minus 2 Days???
date will ruturn the current system date so this will return what you ask for
VB Code:
x = -2
mydate = Format(Date, "dddd ") & Format(DateAdd("d", x, Date), "dd") & Format(Date, "/mm/yyyy")
Debug.Print mydate ' Saturday 02/11/2006
Edit:
you can also try this to see if it gives any useful result
VB Code:
VBA.Calendar = vbCalHijri
Debug.Print Now
VBA.Calendar = vbCalGreg
Debug.Print Now
Last edited by westconn1; Nov 3rd, 2006 at 11:52 PM.
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|