Results 1 to 1 of 1
  1. #1
    Platinum Lounger
    Join Date
    Feb 2001
    Yilgarn region of Toronto, Ontario
    Thanked 0 Times in 0 Posts

    Code:lngDropDuplicateRows(strAr() As String, Optio

    I needed a good algorithm for removing duplicate rows of a string array. Nothing fancy, just compare elelemnts in each row, and if two rows are identical, drop one row.

    Down the road I'll make use of the optional columns identifiers (which columns are to be used in the comparison) and whether it is a case-sensitive comparison, whether to squeeze out white-space characters etc.

    For now it's rough and ready. I'm doing the grunt work of elimiating duplicate entries in a fax telephone-number table.

    I thought of sorting and then eliminating duplicates, but I have no guarantee that the end user would want the array to be sorted. Maybe the array is already in a good sequence.

    So I decided to break the problem into two parts:

    Part1: mark which rows are duplicates
    Part2: delete the marked rows.

    Part1 is a nested loop. I maintain a marker array, same number of rows as the data. The outer loop loops through all rows, the inner loop loops from the outer loop to the end of the array. A typical exhaustive loop.

    If I find a matching row, I set a flag in the marker array, and ignore that row for the rest of Part 1.

    Part2 uses the marker array to shunt useful (non-marked) rows down to the head of the array.

    I didn't mean the (attached) code to be terribly time-efficient. I'm not managing the BELL telephone directory for Toronto.

    I would appreciate comments on the algorithm more than the code.

    And yes, I have an "Exit For" in there!
    Attached Files Attached Files

Posting Permissions

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