Click here to Skip to main content
15,904,153 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:
VB
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

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!! :)
Posted
Updated 3-Jan-12 19:48pm
v3
Comments
Sergey Alexandrovich Kryukov 3-Jan-12 20:22pm    
What is the real run-time type of the list box item you tried to use? You don't have to use System.String -- this is the key.
--SA
Dale 2012 3-Jan-12 23:45pm    
Ok if I understand what your asking about the run time of the list box, there is no actual error but all the same it does not compare with the text file I am using.
Dale 2012 3-Jan-12 23:49pm    
can you give an example of what you mean here...... where have I gone wrong with the code?....
Dale 2012 4-Jan-12 2:48am    
I have seemed to make it work thank you!!

1 solution

you can get by line in a for (with streamreader's readline method) and then you compare the items you need.


regards.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900