我有一個用VB.net創建的程序,其中文本文件用於加載數據網格,但它非常慢,有很多代碼,當有很多從文本文件導入的行。使用vb.net從100k行的文本文件輕鬆快速地加載數據網格
有沒有更簡單的方法來編碼,所以datagrid加載不是很慢?
Private Sub Load_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Load.Click
OpenFileDialog1.Filter = "Text Files|*.txt|All Files|*.*"
OpenFileDialog1.Title = "Select Text File for Path"
OpenFileDialog1.FileName = "Select File"
If OpenFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.Ok Then
txttblnm.Text = OpenFileDialog1.FileName
txtfilenm.Text = System.IO.Path.GetFileName(txttblnm.Text)
txtfilenm.Text = txtfilenm.Text.Substring(0, txtfilenm.Text.Length - 4)
Label7.Text = System.IO.Path.GetDirectoryName(txttblnm.Text)
End If
If Len(txtfilenm.Text) = 8 And CheckBox1.CheckState = CheckState.Checked Then
Dim textfiles() = Directory.GetFiles(Label7.Text, "*.txt")
For Each file As String In textfiles
Call dgv1_load()
Call Access_export()
Call clear_item()
Next
ElseIf Len(txtfilenm.Text) >= 9 Then
MsgBox("Please Load DATA", MsgBoxStyle.Information, "Load Data Error")
Exit Sub
End If
End Sub
你能不能格式化你的代碼示例? –