比较列表框项目与文本文件有问题吗? [英] Compare Listbox items With text file problem?
问题描述
您好,开发人员社区目前,我只是停留在一个似乎很简单的问题上.扫描完成后,我需要能够将列表框中的项目与文本文件中的文本进行比较.到目前为止,我的代码是:
Hello developer community I am currently stuck on what seems to be a simple problem. I need to be able to compare the items in a listbox with the text in a text file once my scan has completed. The code I have so far is:
For Each line As String In resultsbox.Items
If line.contains(md5reader.readtoend) Then
ListBox1.Items.Add(line)
Label7.Text = ListBox1.Items.Count.ToString
End If
Next line
现在我怀疑这段代码的问题是,如果找到匹配项,它将添加它正在比较的列表框中的所有项目,而不仅仅是与文本文件匹配的项目.
结果框是我希望将行与文本文件进行比较的对象
md5reader是我的io流阅读器,程序可以通过它读取文本中的行以结束
然后我要说,如果resultbox items.contains md5reader.readtoend ?,则listbox1项目要添加行?
是否有其他方法可能比我正在使用的方法更快或更可靠?
请告知
先感谢您!! :)
Now the problem with this code I suspect is that if a match is found it will add all items from the list box it is comparing from instead of just the items that match the text file.
resultsbox is the object I wish to compare the lines to a text file
md5reader is my io stream reader by which my program reads the lines in the text to end
I then go to say listbox1 items add line if resultsbox items.contains md5reader.readtoend?
Is there any other method that might be faster or more reliable then the method im using?
Please advise
Thank you in advance!! :)
推荐答案
您可以在for中逐行获取(使用streamreader的readline方法),然后比较所需的项目.
问候.
you can get by line in a for (with streamreader''s readline method) and then you compare the items you need.
regards.
这篇关于比较列表框项目与文本文件有问题吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!