Hi.
I keep getting an out of bounds error on the following code.
Can anyone see where I'm going wrong? Any help would be appreciated.
Thankyou
I keep getting an out of bounds error on the following code.
VB.NET:
Using MyReader As New Microsoft.VisualBasic.FileIO.TextFieldParser(csvfile.Text)
MyReader.TextFieldType = FileIO.FieldType.Delimited
MyReader.SetDelimiters(",")
Dim currentRow As String()
Dim currentField As String
While Not MyReader.EndOfData
Try
currentRow = MyReader.ReadFields()
For Each currentField In currentRow
Dim Fields(2) As String
Fields = Split(Text, ",")
Fields(0) = currentRow(0)
Fields(1) = currentRow(1)
MsgBox(Fields(0))
MsgBox(Fields(1))
Next
Catch ex As Microsoft.VisualBasic.FileIO.MalformedLineException
MsgBox("Line " & ex.Message & _
"is not valid and will be skipped.")
End Try
End While
End Using
Can anyone see where I'm going wrong? Any help would be appreciated.
Thankyou