我读取了CSV文件的前三行,并且没有使用它们。第四行包含一个或两个字母,例如AA或B。我需要在DataGridView的第一栏中显示此字母/这些字母。我阅读了CSV文件的下4行,而忽略了它们(如1-3行)。最后,我阅读了剩余的行,并将其显示在DataGridView的第2-6列中。除了检索CSV文件第4行的值(一个或两个字母)外,其他所有操作都有效。第1列的每一行显示的是System.String []
Using MyReader As New TextFieldParser(racerFile)
Dim currentRow As String()
MyReader.TextFieldType = Microsoft.VisualBasic.FileIO.FieldType.Delimited
MyReader.Delimiters = New String() {","}
currentRow = MyReader.ReadFields()
currentRow = MyReader.ReadFields()
currentRow = MyReader.ReadFields()
currentRow = MyReader.ReadFields()
Dim boatClass As String
boatClass = currentRow.ToString
currentRow = MyReader.ReadFields()
currentRow = MyReader.ReadFields()
currentRow = MyReader.ReadFields()
currentRow = MyReader.ReadFields()
While Not MyReader.EndOfData
Try
Dgvs.Rows.Add()
currentRow = MyReader.ReadFields()
Dgvs(0, rd).Value = boatClass
Dgvs(1, rd).Value = currentRow(1)
Dgvs(2, rd).Value = currentRow(2)
Dgvs(3, rd).Value = currentRow(3)
Dgvs(4, rd).Value = currentRow(4)
Dgvs(5, rd).Value = currentRow(5)
rd += 1
Catch ex As Exception
End Try
End While
End Using