我的文本文件中有超过十万行的数据,每一行具有相同的数据格式,比如“2008-01-01 00:05:00,15.56”,我想把它导入到Datagirdview控件中,我采用如下的方法,但是导入一个文件用时10分钟以上,太慢了,请大家帮我想想,有更好的方法吗?
FileOpen(1, FileName, OpenMode.Input)
Dim textline(150000) As String, i As Integer
DataGridView1.Rows.Clear()
While Not EOF(1)
textline(i) = LineInput(1)
Me.DataGridView1.Rows.Add()
Me.DataGridView1.Rows(i).Cells(0).Value = i + 1
Me.DataGridView1.Rows(i).Cells(1).Value = Mid(textline(i), 1, 19)
Me.DataGridView1.Rows(i).Cells(2).Value = Mid(textline(i), 20, 28)
Application.DoEvents()
i = i + 1
'WriteLine(1, TextLine)
End While
FileClose(1)