I have this code which works with the filepath but I am trying to get it to change the text to "Search completed" once it is done searching. This is what I tried and I tried it without the quotes around 100 but it still isn't working, any pointers.
Private Sub BackgroundWorker1_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
Dim argument = DirectCast(e.Argument, Tuple(Of String, String))
Dim target = argument.Item1
Dim folderPath = argument.Item2
Dim filePaths = IO.Directory.GetFiles(folderPath, "*.txt")
'Report the total file count.
Me.BackgroundWorker1.ReportProgress(filePaths.Length)
For Each filePath In filePaths
'Report progress.
Me.BackgroundWorker1.ReportProgress(CInt(False), filePath)
If IO.File.ReadAllText(filePath).Contains(target) Then
'Report a successful search.
Me.BackgroundWorker1.ReportProgress(CInt(True), filePath)
End If
Next
End Sub
Private Sub backgroundworker1_ProgressChanged(ByVal sender As Object, ByVal e As System.ComponentModel.ProgressChangedEventArgs) Handles BackgroundWorker1.ProgressChanged
Dim filePath = DirectCast(e.UserState, String)
If filePath Is Nothing Then
'This is the total file count.
Me.dataprogbar.Maximum = e.ProgressPercentage
ElseIf CBool(e.ProgressPercentage) Then
'This is a successful search.
Me.ListBox1.Items.Add(filePath)
Else
'This is a simple progress update.
Me.dataprogbar.PerformStep()
Me.Label1.Text = filePath
If dataprogbar.Value = "100" Then
Label1.Text = "Search Completed"
End If
End If
End Sub