2
I’m developing a new software which checks digital signatures and has 2 ListBox
. The first with the hash from the files contained in the Directory chosen by the user, the second with the signatures MD5
of known viruses I need to compare item by item if in listbox4.items.contain(listbox5.items)
.
How can I do this loop
and compare with all existing keys
one by one?
Ever since I thank.
I’ve Googled but I can’t find anything that can help me.
This is my code:
Private Sub comparador_Tick(sender As Object, e As EventArgs) Handles comparador.Tick
For Each hash1 As String In ListBox4.Items
ListBox4.SelectedIndex = ListBox4.SelectedIndex + 1
For Each hash2 As String In ListBox5.Items
ListBox5.SelectedIndex = ListBox5.SelectedIndex + 1
If ListBox4.Items.Contains(ListBox5.SelectedItem) Then
MsgBox("Virus Encontrado Em:" & ListBox4.SelectedItem)
Else
End If
If (ListBox4.SelectedIndex = ListBox4.Items.Count - 1) Then
Return
End If
If (ListBox5.SelectedIndex = ListBox5.Items.Count - 1) Then
Return
End If
Next
Next
End Sub
After making a few attempts I ended up modifying some of my initial code to this: Comparator and a timer
Private Sub comparador_Tick(sender As Object, e As EventArgs) Handles comparador.Tick
ListBox4.SelectedIndex = 0
ListBox5.SelectedIndex = 0
'ListBox4.SelectedIndex = ListBox4.SelectedIndex + 1
For Each hashf As String In ListBox5.Items
If ListBox4.SelectedItem.ToString = ListBox5.SelectedItem.ToString
Then
MsgBox("Virus Encontrado Em:" & ListBox4.SelectedItem)
Else
ListBox5.SelectedIndex = ListBox5.SelectedIndex + 1
End If
ListBox4.SelectedIndex = ListBox4.SelectedIndex + 1
Next
End Sub
error The list to which this enumerator is linked has been modified. A enumerator can only be used if the list does not change. In fact after trying many things I found a solution
Private Sub comparador_Tick(sender As Object, e As EventArgs) Handles comparador.Tick
TextBox3.Text = ListBox5.Items.Count
Dim counter As Integer 'new!
'ListBox4.SelectedIndex = ListBox4.SelectedIndex + 1
For Each hashf As String In ListBox5.Items.ToString
ListBox5.SelectedIndex = ListBox5.SelectedIndex + 1
counter += 1 'new
ProgressBar1.Value = (counter * 100) / ListBox5.Items.Count 'new
If (ListBox5.SelectedIndex = ListBox5.Items.Count - 1) Then
ListBox5.SelectedIndex = 0
ListBox4.SelectedIndex = ListBox4.SelectedIndex + 1
End If
ListBox4.SelectedIndex = 0
If ListBox4.SelectedItem.ToString = ListBox5.SelectedItem.ToString Then
MsgBox("Virus Encontrado Em:" & ListBox4.SelectedItem)
End If
Next
End Sub
I tried your code but error me on strVirusFound line += $
– Helder Da Silveira Ventura
the error and in the character $
– Helder Da Silveira Ventura
are actually a md5 hash list
– Helder Da Silveira Ventura
If I’m not mistaken to use the
$
have to have the . NET Framework 4.5.2 at least. I will edit the reply with a more comprehensive solution.– João Martins