我正在从 CSV 文件中读取数据,我的目标是只获取选定的列,但是到目前为止,我只能循环获取标题。有人可以帮助我循环直到我得到行吗?
导入 System.IO 公共类 Form1
Private Sub btn_import_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_import.Click
Call csvmanagement()
End Sub
Structure systemstructure
Dim cGroupName As String
Dim cTransactDate As String
Dim cRow_ID As String
Dim cFullName As String
End Structure
Public Sub csvmanagement()
Dim systemspecs As New systemstructure
'Dim raw, column As Integer
Using csvparser As New FileIO.TextFieldParser _
("C:\Users\Eranji\Downloads\new.csv")
Dim csvalue As String()
csvparser.TextFieldType = Microsoft.VisualBasic.FileIO.FieldType.Delimited
csvparser.Delimiters = New String() {","}
csvalue = csvparser.ReadFields()
systemspecs.cGroupName = csvalue(0)
systemspecs.cTransactDate = csvalue(1)
systemspecs.cRow_ID = csvalue(2)
systemspecs.cFullName = csvalue(2)
While Not csvparser.EndOfData
End While
csvalue = csvparser.ReadFields()
End
ListBox1.Items.Add(systemspecs.cFullName & Chr(9) & systemspecs.cGroupName & Chr(9) & systemspecs.cRow_ID & systemspecs.cTransactDate)
End Using
End Sub
结束类