Results 1 to 2 of 2

Thread: VB6 -- Find all differences between two strings/files (FAST).

  1. #1

    Thread Starter
    Fanatic Member Comintern's Avatar
    Join Date
    Nov 2004
    Location
    Lincoln, NE
    Posts
    826

    VB6 -- Find all differences between two strings/files (FAST).

    Just a module that I cooked up for doing string/file comparison. Pass it two strings, and it returns a comma delimited string of character positions that are unmatched in the other string. So, to get all changes (insertions and deletions) it would need to be called twice. For example, if given these two strings:

    Original = "This is a test string."
    Changed = "This was a test thing."

    The output would be something like this:
    6,16,18 in string 1 were deleted.
    6,7,18 in string 2 were inserted.

    To give you an idea of how fast this runs, given 1MB test strings with 20 random insertions and 20 random deletions, it averages about .3 seconds per comparison (uncompiled, and on my slow-a** work computer).

    The zip file includes one .bas with the actual code "StringDiff.bas" and one with some test code to demo how to use it.
    Attached Files Attached Files

  2. #2
    Fanatic Member
    Join Date
    Aug 2011
    Location
    Palm Coast, FL
    Posts
    760

    Re: VB6 -- Find all differences between two strings/files (FAST).

    Nice module. Very useful. However, there is a bug.

    Compare these two strings of text:

    use GetFileAttributesW is the best way
    use FindFirstFileW

    Notice that the "W" in the first line is stated to be similar while the "W" in the second line is shown to differ.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width