我有一个大问题。我尝试将数据从文件加载到列表框,但是当我加载它时,我在文件的最后一行出现异常。它说“值不能为空。参数名称:项目”。我使用此代码
ListBox2.Items.Clear() 'clear listbox2
For i As Integer = 0 To ListBox1.Items.Count - 1
Dim read_text As New StreamReader(ListBox1.Items.Item(i).ToString, System.Text.Encoding.GetEncoding(1250)) ' listbox1.items.item(i) is the path of file I load data from
Try
Do While read_text.Peek >= 0
If read_text.ReadLine.ToString.Contains(":") Then 'dont load lines without ":" mark
ListBox2.Items.Add(read_text.ReadLine)
End If
Loop
read_text.Close()
Catch ex As Exception
MsgBox(ex.Message)
End Try
Next i
哪里有问题?有人可以帮忙吗?;)