I've been having loads of trouble pulling dates from excel and loading them into an array. I have code that should, for all intents and purposes work, but nothing is being loaded into the array. When I do a search in the array for a value, no matter what it is, it says it has been found at Index -1 in the array. Code is as follows.
Dim d As String
Dim strDate(0 To 35) As String
Dim dCell As Object
Dim tDate As String = Now.ToShortDateString
Dim dCount = WFMBook.Range("G2:AO2").Cells.Count
For y = 1 To dCount Step +1
For Each dCell In WFMBook.Range("G2:AO2").Cells(y).Value.ToString
d = WFMBook.Range("G2:AO2").Cells.Value.ToString
Next
strDate(y) = d
TextBox1.Text = strDate(0)
Next
And then after all the data is supposedly loaded into the array (I have the textbox function to check whether things are in the array -- no results are printed into the textbox.) I perform this function:
Dim dindex As Integer = Array.FindIndex(strDate, Function(s2) s2 = tDate)
MsgBox("Found Date " & tDate & " at index " & dindex)
As I said previously, though, the MsgBox shows that it was found at index -1, and no array results are ever printed to the textbox. I believe it has something to do with Excel Date/Time somehow. How can I get this to properly load the dates into a string format ex "12/3/2015" into an array? Thanks!