I am trying to read a line from a text file and store it in a DateTime
veritable. Below is a cut down version of my problem code (in my
actual version I am using a try and catch, and I am receiving each
line in a loop to store into the Array)
If I write the string directly into the array it works, but when I use
the line from the file it doesn't go into the DateTime veriable and I
get an error. Is there something I am missing?
Dim inputArray(2) As String
FileOpen(1, "F:/DestinationTime.txt", OpenMode.Input)
inputArray(2) = LineInput(1)
FileClose(1)
Dim temp As DateTime = CDate(inputArray(2)) 'Problem Line
The line in the file reads:
9/14/2004 6:00:00 PM
And yes I have tired adding #s.
And I even tired Option Explicit Off
The error I get is:
An unhandled exception of type 'System.InvalidCastException' occurred
in microsoft.visualbasic.dll
Additional information: Cast from string "9/14/2004 6:00:00 PM" to
type 'Date' is not valid.
I bet it's something dead simple.