I have made an inefficient filtering program that someone may be able to help me with. I am using lines from "FILE A" (aka "A") to match against lines that appear in "FILE B" (aka "B"). I would like to remove this information from "B" as soon as the match is made.
As it stands now, the program loops through "B" for every line in "A" trying to find a match. If a match is made, then the data is stored in a QUEUE. After the loop has cycled through all the lines in "A", all the data from "B" is stored in an ARRAY.
Finally, another loop is made to cycle through the ARRAY for every item in the QUEUE trying to make a match. Where the line matches, the current element in the ARRAY is set to nothing. With this loop ending, I print the every element of the ARRAY (minus the blank ones) to a file.
I realize this may be a little hard to understand, but it may help with the following code. Also, the variables might be confusing for i did not spend time trying to name them :
As it stands now, the program loops through "B" for every line in "A" trying to find a match. If a match is made, then the data is stored in a QUEUE. After the loop has cycled through all the lines in "A", all the data from "B" is stored in an ARRAY.
Finally, another loop is made to cycle through the ARRAY for every item in the QUEUE trying to make a match. Where the line matches, the current element in the ARRAY is set to nothing. With this loop ending, I print the every element of the ARRAY (minus the blank ones) to a file.
I realize this may be a little hard to understand, but it may help with the following code. Also, the variables might be confusing for i did not spend time trying to name them :
Code:
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim count As Integer
Dim count2 As Integer
Dim count3 As Integer
Dim int As Integer = qCreatedFiles.Count - 1
Dim strFileDataBase As String
Dim strDBCommand As String
Dim strFileTitle As String
ProgressBar1.Visible = True
ProgressBar1.Minimum = 1
ProgressBar1.Value = 1
ProgressBar1.Step = 1
For count2 = 0 To int
strFileTitle = qCreatedFiles.Dequeue
strDBCommand = "SELECT * From " & strFileTitle
cmd = New OleDbCommand(strDBCommand)
objCmd.SelectCommand = cmd
objCmd.SelectCommand.Connection = con
objCmd.Fill(ds, strFileTitle)
ProgressBar1.Maximum = ds.Tables(strFileTitle).Rows.Count
For count = 0 To ds.Tables(strFileTitle).Rows.Count - 1
strFileDataBase = ds.Tables(strFileTitle).Rows(count)(0)
FileScan(strFileDataBase, strFileTitle)
ProgressBar1.PerformStep()
Next
ProgressBar1.Value = 1
ds.Tables(strFileTitle).Clear()
Print_to_File(strFileTitle)
Next
End Sub
Sub FileScan(ByVal str As String, ByVal strFileTitle As String)
Dim count As Integer
Dim count2 As Integer
Dim intBuf As Int16 = FreeFile()
Dim strFileData As String
FileOpen(intBuf, "C:\Documents and Settings\Owner\Desktop\Docs\" & strFileTitle & ".txt", OpenMode.Input)
Do Until EOF(intBuf)
strFileData = LineInput(intBuf)
If str = strFileData Then
qMatchedString.Enqueue(str)
FileClose(intBuf)
Return
End If
If strFileData = "" Then
FileClose(intBuf)
Return
End If
Loop
FileClose(intBuf)
End Sub
Last edited by a moderator: