The following line gives me a "String was not recognized by a valid DateTime" error:
DateTime.ParseExact("4/6/2016", "dd/MM/yyyy", Nothing)
I got this "working" example on stackoverflow, but it doesn't work for me: Parse Exact Sample and I can't figure out why.
EDIT (reedit, I mistakenly typed the last two attempts wrong): Still no good. This is what I've found after trying all the suggestions submitted so far (thanks all). Some more info, the date string is coming from a textbox control.
Dim xxx As String = "4/6/2016" 'OR = "04/06/2016" as necessary for the sample
This does not work:
DateTime.ParseExact(xxx, "M/d/yyyy", CultureInfo.InvariantCulture)
This does not work:
DateTime.ParseExact(xxx, "MM/dd/yyyy", CultureInfo.InvariantCulture)
After, I tried something simpler with just DateTime.Parse:
DateTime.ParseExact(xxx)
I typed this out by hand. I did NOT use values from a textbox control and it DID work:
DateTime.Parse("4/6/2016")
So frustrating