Compare two string / word and highlight

Posted by Dot Net Team under VB.NET on 1/14/2012 | Points: 10 | Views : 4391 | Status : [Member] | Replies : 1
I have two text box,
text box1 is contain "all are welcome by Raja" and
text box2 is contain "all are welcome by Dot Net funda",
Compare these two text boxes and highlight(bold or color change) the different words, how to do? using 2003.
display the same text box only highlight(bold or color change) that words.



Posted by: Naraayanan on: 2/3/2012 [Member] Starter | Points: 25

Hi ,
Try this Code .I hope ,it will help you

Private Function CompareText(fValue As String, svalue As String) As String

Dim formHeading As String = fValue
Dim userSearch As String = svalue
Dim constring As String = String.Empty
Dim comstring As String = String.Empty
Dim formHeadingWords As String()
Dim userSearchWords As String()
formHeadingWords = System.Text.RegularExpressions.Regex.Split(formHeading, "\W")
userSearchWords = System.Text.RegularExpressions.Regex.Split(userSearch, "\W")
For Each _str As String In userSearchWords
If Not formHeading.Contains(_str) Then
comstring = _str
End If

constring = constring & " " & comstring

Return constring

End Function

Lakshmi Naraayanan.S

Dot Net Team, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response