title: Compare two strings and highlight words which are different
body: <p>I have two strings which are received via textboxes, Is there a way in vb.net to compare the two strings, and highlight in a different colour the differences?</p>
  
  <p>What I have done so far is:</p>
  
  <pre><code>Dim txt1(textbox1.Text.Split(CType(" ", Char())).Length) As String
  Dim txt2(textbox2.Text.Split(CType(" ", Char())).Length) As String
  txt1 = textbox1.Text.Split(CType(" ", Char()))
  txt2 = textbox2.Text.Split(CType(" ", Char()))
  
  Dim diff1 As String = "" 'Differences between 1 and 2
  Dim diff2 As String = "" 'Differences between 2 and 1
  
  For Each diff As String In txt1
      If Array.IndexOf(txt2, diff.ToString) = -1 Then
          diff1 += diff.ToString &amp; " - "
      End If
  Next
  
  For Each diff As String In txt2
      If Array.IndexOf(txt1, diff.ToString) = -1 Then
          diff2 += diff.ToString &amp; " - "
      End If
  Next
  Response.Write("Difference in First To Second: " &amp; diff1 &amp; vbNewLine &amp; "Difference in Second To First: " &amp; diff2)
  </code></pre>
  
  <p>But I am trying to get the words which are different to be highlighted in the second textbox which are different from the first.</p>
  
  <p>Help is appreciated :)</p>