none
about showing hijri date in textbox userform vba RRS feed

  • Question

  • dears

    good greeting


    i have made textboxi't's import date from sheet but in georgian date(2018)

    i want to creat another textbox showing the date that it appear in first textbox but in hijrian date (1439)

    i mean that georgian date that will appear in textbox 1

    showing in same time the hijrian date in next textbox

    but i need this code to work by moving between two textbox without prees command button

    thanks...............

    Tuesday, March 6, 2018 10:27 AM

Answers

  • Hello TAREK SHARAF,

    Please refer to below code and demonstration.

    Note that I set date string to text box1 directly, if you need enter text box 1 to enter a date string, using AfterUpdate event instead of Change event.

    Private Sub CommandButton1_Click()
    Me.TextBox1.Text = ThisWorkbook.Worksheets(1).Range("A1").Value
    End Sub
    
    Private Sub TextBox1_Change()
    Dim objDate As Date
    If IsDate(Me.TextBox1.Value) Then
    objDate = Me.TextBox1.Value
    VBA.Calendar = vbCalHijri
    Me.TextBox2.Text = objDate
    VBA.Calendar = vbCalGreg
    End If
    End Sub

    Best Regards,

    Terry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by TAREK SHARAF Wednesday, March 7, 2018 12:12 PM
    Wednesday, March 7, 2018 2:42 AM

All replies

  • Hello TAREK SHARAF,

    Please refer to below code and demonstration.

    Note that I set date string to text box1 directly, if you need enter text box 1 to enter a date string, using AfterUpdate event instead of Change event.

    Private Sub CommandButton1_Click()
    Me.TextBox1.Text = ThisWorkbook.Worksheets(1).Range("A1").Value
    End Sub
    
    Private Sub TextBox1_Change()
    Dim objDate As Date
    If IsDate(Me.TextBox1.Value) Then
    objDate = Me.TextBox1.Value
    VBA.Calendar = vbCalHijri
    Me.TextBox2.Text = objDate
    VBA.Calendar = vbCalGreg
    End If
    End Sub

    Best Regards,

    Terry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by TAREK SHARAF Wednesday, March 7, 2018 12:12 PM
    Wednesday, March 7, 2018 2:42 AM
  • dear mr/Terry


    thank you so much my dear friend

    but i need to repeat this code to transfer the date from hijri to georgian

    i'm tried to made some modification in your last code but it stoped working unfortunatly 

     i need to enter hijri date in textbox1 and transfered to georgian date in textbox2 (can you made it just by key press -i mean that the the resulat in textbox 2 appar once i'm starting type in textbox1

    i'm tried to made this modification to your code but it did not work

    Private Sub TextBox118_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
    Dim objDate As Date
    If IsDate(Me.TextBox118.Value) Then
    objDate = Me.TextBox118.Value
    VBA.Calendar = vbCalGreg
    Me.TextBox119.Text = objDate
    VBA.Calendar = vbCalHijri
    End If
    End Sub

    code 

    )

    accept my greetings




    Wednesday, March 7, 2018 11:26 AM