I've a situation here.
Public Shared Function ConvertStringToDateTime(ByVal s As String) As [Object] Dim format As New System.Globalization.CultureInfo("en-GB", True) Return DateTime.Parse(s, format)End Function
This function can't parse the string correctly and throw me the "Object reference not set to an instance of an object." error message.
I've this line in my Web.config file as well.
<globalization requestEncoding="utf-8" responseEncoding="utf-8" culture="en-GB" />
When I set the CultureInfo in my ConvertStringToDateTime function to false, or when I remove the format when I parse the string into the DateTime, NO ERROR.
For more information, my current Regional and Language Options is set to English (United Kingdom).
Any idea what cause this?
Thanks and regards,
eddykuan
oh yeah, forgot this information. i try debug it and step into the function, the string, s, that i pass in was "21/06/2007".
thanx ;)
Check out this link: http://www.developerfusion.co.uk/show/4690/ for your answer.
information provided was in deed very useful...
however, the recommendation of using the 'ukCulture.DateTimeFormat' isn't helpful...
same error message still occured...
huh???
Hi Eddy,
I've tried your code and hit no error. Maybe you can paste the error stack trace here.
Just curious, why you use Object as the return value type?