Comparison of two strings RRS feed

  • Question

  • User651462752 posted

    I'm trying to do something in VB, and I can't even begin to guess how to accomplish the logic.

    I'm trying to compare to strings, original and new.

    I want to display the new, with markings showing the changes. Exactly how wiki.asp.net does it when you compare revisions.

    Can anybody give me a nudge in the write direction?

    Thursday, March 6, 2008 8:13 PM

All replies

  • User-1358897060 posted
    Use something like this:

    str1 As String = "Orignal Version"
    Dim str2 As String = "Modified Version"
    Dim i As Integer = 0

    For Each c As Char In str1.ToCharArray()
             If Not c.Equals(str2(i)) Then
                      ' Not Same, Write your code.
             End If
             i = i + 1

    Friday, March 7, 2008 5:16 AM
  • User651462752 posted

    Sounds like were on the right track, but I see a problem.

    When I then find an addition, how do I update the i integer to the next unchanged content to begin comparing again?

    Monday, March 17, 2008 9:53 AM
  • User651462752 posted

    Maybe the asp.net wiki creators would be nice enough to share the code they used to show changes between revisions?

    Monday, March 17, 2008 9:55 AM
  • User651462752 posted

    I contacted Scott and he was nice enough to share the method. While he didn't give me the source code (of course), he pointed me to some assemblies that did the job.

    Thanks ScottHa!

    Wednesday, March 19, 2008 11:12 AM
  • User-2068011911 posted

    Could you post an example - I am trying to do about the same thing


    Tuesday, April 29, 2008 12:02 PM