I am developing a new software that verifies digital signatures and I have 2 ListBox
. The first one with the hash that is obtained from the files contained in the directory chosen by the user, the second with the known% signatures of% virus I need to compare item by item if in MD5
.
How can I make this listbox4.items.contain(listbox5.items)
and compare with all existing keys
one by one?
Thank you in advance.
I already searched on Google but did not find anything that could 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 for 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. An enumerator can only be used if the list does not change. In fact after trying several 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