Date Conversion Hijri to Gregorian

S

SalimShahzad

Dear Respected Gurus,

I need a coding assistant converting from gregorian to hijri and vice
versa. I have problem with this codes. the problem Gregorian to Hijri
gives 100% results. when i enter this to Hijri to gregorian it either
do nothing or go to next record on form. well there r two fields on
form that r calc afterevents each other dates.

ur assistance will be highly appreciated, if any one can tell what is
wrong with this codes

Function strHijri(dtGregorian As Date) As String
' returns a date in Hijri format for a given western date
VBA.Calendar = vbCalHijri
strHijri = Day(dtGregorian) & "/" _
& Month(dtGregorian) & "/" _
& Year(dtGregorian)
VBA.Calendar = vbCalGreg
End Function

Function strGregorian(dtHijri As String) As String
' returns a date in Hijri format for a given western date
VBA.Calendar = vbCalGreg
strGregorian = Day(dtHijri) & "/" _
& Month(dtHijri) & "/" _
& Year(dtHijri)
VBA.Calendar = vbCalHijri

End Function
 
P

pietlinden

SalimShahzad said:
Dear Respected Gurus,

I need a coding assistant converting from gregorian to hijri and vice
versa. I have problem with this codes. the problem Gregorian to Hijri
gives 100% results. when i enter this to Hijri to gregorian it either
do nothing or go to next record on form. well there r two fields on
form that r calc afterevents each other dates.

ur assistance will be highly appreciated, if any one can tell what is
wrong with this codes

Function strHijri(dtGregorian As Date) As String
' returns a date in Hijri format for a given western date
VBA.Calendar = vbCalHijri
strHijri = Day(dtGregorian) & "/" _
& Month(dtGregorian) & "/" _
& Year(dtGregorian)
VBA.Calendar = vbCalGreg
End Function

Function strGregorian(dtHijri As String) As String
' returns a date in Hijri format for a given western date
VBA.Calendar = vbCalGreg
strGregorian = Day(dtHijri) & "/" _
& Month(dtHijri) & "/" _
& Year(dtHijri)
VBA.Calendar = vbCalHijri

End Function

Did you check MichKa's site? www.trigeminal.com? He's the resident
internationalization guru...
 
P

pietlinden

See?!! I knew it was there! Makes me think I'd be better as a
librarian than a programmer!
 
S

SalimShahzad

Dear Gurus,

There is problem in passing date as string, can any one send reference
of codes will help a bit for me. as in text box, table field has set as
date.

when i call as msgbox under "1/1/2005" or "1/1/1426" it gives 100%
results, but when i used via text box value putting it gives unexpected
dates or results

i had try following

MsgBox StDteHijriOfStDteGreg("'" & Dt_Dob_en.Value & "'")
MsgBox StDteHijriOfStDteGreg( Dt_Dob_en.Value)
MsgBox StDteHijriOfStDteGreg(cstr(Dt_Dob_en.Value))

even i define as string variable and pass value to this and then try
but the results is same...

can any one help me how to pass date as string to function in modules
thanks and rgds
shahzad
 
P

pietlinden

SalimShahzad said:
Dear Gurus,

There is problem in passing date as string, can any one send reference
of codes will help a bit for me. as in text box, table field has set as
date.

when i call as msgbox under "1/1/2005" or "1/1/1426" it gives 100%
results, but when i used via text box value putting it gives unexpected
dates or results

i had try following

MsgBox StDteHijriOfStDteGreg("'" & Dt_Dob_en.Value & "'")
MsgBox StDteHijriOfStDteGreg( Dt_Dob_en.Value)
MsgBox StDteHijriOfStDteGreg(cstr(Dt_Dob_en.Value))

even i define as string variable and pass value to this and then try
but the results is same...

can any one help me how to pass date as string to function in modules
thanks and rgds
shahzad


You REALLY need to make friends with the helpfile. REALLY. How about
using something like oh, I dunno... CDATE() or DATESERIAL or one of
those other handy dandy conversion/date functions. Or shock of shocks,
pass the stupid thing as a DATE, not a text string.
 
Joined
Aug 21, 2013
Messages
1
Reaction score
0
I have created a excel file with macro which will convert the Hijri date to Grogorian . If anyone need this file , please mail to me hanseljose(gmail.com)(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top