Well, I did try , but couldn't come up with what I wanted..I need to compare two text files and count the character differences between them..like in a typing test program.The code I came up with just checks if a word exists in the parent file, (irrespective of the position). Please suggest the changes, I need to make to my current code..
Here's the code:
CODE
Dim sr As StreamReader
Dim strFile1, strFile2 As String
Dim strFile1Lines(), strFile2Lines() As String
Dim strFile1NotFile2 As String = ""
Dim strFile2NotFile1 As String = ""
' Open File1
sr = New StreamReader(file1)
strFile1 = sr.ReadToEnd()
sr.Close()
'Open File2
sr = New StreamReader(file2)
strFile2 = sr.ReadToEnd()
sr.Close()
'delimiter for splitting strings
Dim delim() As String = {" ", vbCrLf}
' Seperate the contents of File1 and File2 into words
strFile1Lines = strFile1.Split(delim, StringSplitOptions.RemoveEmptyEntries)
strFile2Lines = strFile2.Split(delim, StringSplitOptions.RemoveEmptyEntries)
' Going through each word in File 1
For Each strFile1Line As String In strFile1Lines
Dim bLineInFile2 As Boolean = False
' Compare the current word in File1 against all lines in File2
For Each strFile2Line As String In strFile2Lines
If strFile1Line = strFile2Line Then bLineInFile2 = True
Next
' If the word is in not in File2 add it to the variable strFile1NotFile2
If Not bLineInFile2 Then strFile1NotFile2 = strFile1NotFile2 & strFile1Line & vbCrLf
Next
'display the unmatched words in a richtextbox
RichTextBox1.Text = strFile1NotFile2