Q:

Entering Date in Excel Sheet in VB. Date format changes if day is entered less than 12

This is my Code :
'HomeP form has the excelapp, excelwb, excelws objects initialized.

HomeP.excelws.Range("C1", "C900000").NumberFormat = "dd-MMM-yyyy"
HomeP.excelws.Range("D1", "D900000").NumberFormat = "dd-MMM-yyyy"

I'm taking input using a textbox.
HomeP.excelws.Cells(2, 3).Value = TextBox3.Text
HomeP.excelws.Cells(2, 4).Value = TextBox4.Text

[EDIT] : Now the issue is, if I enter '23-12-2001' then it will store as '23-Dec-2001' in excel but if I enter '01-11-2001' then it will store it as '11-Jan-2001'. I don't think it's about the input but how Excel interprets it when the day is less than 12. My system date format is dd-mm-yyyy. I want to have date format in excel cell as 'dd-MMM-yyyy'

A:

i think you can try :
        Dim Timee As DateTime = HomeP.excelws.Cells(2, 3).Value
        Dim Formatt As String = "dd-MM-yyyy"
        Dim newdate = Timee.ToString(Formatt)
        TextBox3.Text = newdate

and please tell me if it work !!

