Hi Marina
I switched on Strict as you suggested. I have also worked out a solution to
my problem; although I still don't understand exactly what is going on. By
the way, I had to change the date because otherwise I was getting an
exception that the date was not in the correct format.
Here is my new code:
Dim myDate As DateTime = CDate(DateValueRow("The Date"))
Dim newStringDate As String = "The Date is " + Format(myDate, "MM/dd/yy")
If I don't use Format, and use
Dim newStringDate As String = "The Date is " + myDate.ToString()
I still get the error message that the date is in the wrong format i.e.
inspection of the dates, even by Writeline, shows that the day and month
numbers are swapped in the two different codes.
Any further help would be most appreciated.
Geoff
"Marina" <so*****@nospam.com> wrote in message
news:Ok**************@tk2msftngp13.phx.gbl...
I am guessing that you have your PC set to a different date format then
american? Perhaps the debugger is not recognizing that, but the ToString
method of the datetime class does.
Also, you should turn option strict on, which will force all your
variables to have types, and not allow you to just add together variables of
different types.
"Geoff Jones" <ge***@NODAMNSPAM.com> wrote in message
news:40***********************@news.dial.pipex.com ... Hi
I've just found something very strange when using Date types within
string. Consider the following:
Dim myDate = DateValueRow("The Date")
' myDate is a date taken from a DataTable
' During debugging in a watch window it had value 5/28/03
Dim newStringDate = "The Date is " + myDate
' The value of newStringDate is now 28/05/03 i.e. the month and day have
swapped.
Can anybody explain why this is happening and how to avoid it?
Thanks in advance
Geoff