I recently made a program for searching logs... Though It works, but I'm trying to make it faster.... hopefully you guys can enlighten me.
VB Code:
Private Sub btSearch_Click() Dim Count As Integer Dim Results As String Dim i As Integer Dim OneFile As String DisableControls LoadWordList ProgressBar1.Value = 0 If Option1.Value = True Then FindInText "", tbContent.Text, Count, Results Else ProgressBar1.Visible = True For i = 1 To AllFiles.Count On Error Resume Next Open AllFiles.Item(i) For Input As #1 OneFile = Input(LOF(1), #1) FindInText AllFiles.Item(i) & vbTab & ":", OneFile, Count, Results Close #1 Dim NewValue As Integer NewValue = ProgressBar1.Value + ((FileLen(AllFiles.Item(i)) / 10) / AllFilesSize) * 100 If NewValue < 100 Then ProgressBar1.Value = ProgressBar1.Value + ((FileLen(AllFiles.Item(i)) / 10) / AllFilesSize) * 100 Else ProgressBar1.Value = 100 End If Next ProgressBar1.Visible = False End If Form3.tbCount.Text = Count Form3.tbResults.Text = Results EnableControls Form3.Show End Sub Private Sub FindInText(Label As String, Text As String, ByRef Count As Integer, ByRef Results As String) Dim StartIndex, EndIndex, i As Integer Dim Sentence As String EndIndex = 0 While EndIndex < Len(Text) StartIndex = EndIndex + 1 EndIndex = InStr(StartIndex, Text, vbLf, vbTextCompare) If EndIndex = 0 Then Sentence = Mid(Text, StartIndex) EndIndex = Len(Text) Else Sentence = Mid(Text, StartIndex, EndIndex - StartIndex - 1) End If For i = 0 To Form2.lbWords.ListCount - 1 If InStr(1, Sentence, Form2.lbWords.List(i), vbTextCompare) > 0 Then Results = Results + Label + Sentence + vbCrLf Count = Count + 1 End If Next Wend End Sub




Reply With Quote