English date convert to Arabic Date

Shows how to convert English date to arabic date

Put a Date TimePicket and a Text box object in the from which name dtpFrom and txtarDate. Change any date from the dtpFrom its automatic change the Arabic in the txtArDate text box.


Private Sub dtpFrom_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dtpFrom.ValueChanged
Me.txtArDate.Text = HDate(Me.dtpFrom.Value) & " H"
End Sub

Here Hdate function Caculate Arabic date. This fuction put in the Module.

Public Function HDate(ByVal DateEntry As Date)
Dim xx As Date
Dim adj_days, x, d, M, xdate1, xdate2, xdate3, Arabicdate
xx = "02/15/1592"
adj_days = -Year(DateEntry) + 2000
x = DateDiff("d", xx, DateEntry) + adj_days
d = Int(((x / 29.5) - Int(x / 29.5)) * 29.5)
M = Int((((x / 354) - Int(x / 354)) * 354) / 29.5)
xdate1 = Right(Str(100 + d + IIf(d = 0, 30, 0)), 2)
xdate2 = Right(Str(100 + M + IIf(M = 0, 12, 0) - IIf(d = 0, 1, 0)), 2)
xdate3 = Str(1000 + Int(x / 354) - IIf(M = 0, 1, 0))
Arabicdate = xdate1 + "/" + xdate2 + "/" + Trim(xdate3)
HDate = Arabicdate
End Function


Comments

Guest Author: Haider14 May 2012

Thank you very much this is an excellent code, I would be very happy if you make one that converts from Arabic to English Date



  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: