Question

I'm having a bit of a problem figuring out how to pause a for...next loop to await user interaction. I'm comparing the hashes of different files in a for...next loop and if they are different, I want to pause the loop until the user decided which file to keep.

Here's my code, so i hope you see what I'm trying to do.

 For i = 0 To ListBox1.Items.Count - 1
        If GetCRC32(ListBox1.Items.Item(i)) = GetCRC32(ListBox2.Items.Item(i)) Then
            log("same")
        Else

            Dim v1 As String = ListBox1.Items.Item(i)
            Dim v2 As String = ListBox2.Items.Item(i)
            Dim f1 As New FileInfo(v1)
            Dim f2 As New FileInfo(v2)
            Dim c As String
            If f1.LastWriteTime > f2.LastWriteTime Then
                c = v1
            Else
                c = v2
            End If
            RichTextBox1.Text = v1 & " and " & v2 & " seem to be different." & vbCrLf & _
                "Last changed:" & c
        End If
    Next

The user-interaction is via two buttons, which I have no code for yet...

Était-ce utile?

La solution

Why dont you use Form.ShowDialog in the loop. Stops execution of the loop and you can ask user whatever question you need.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top