Removing DUpicate Entries in an Array
Posted on 2000-03-27
I am writing a VB app that will take an external file and read it into an array.
I then want to parse the array and remove any duplicate entries. The entries are name, email addy pairs, and I am only concerned with duplicate email addys and that is why I am stepping by 2 through the arrays. I have made 2 identical copies of the array and have been attempting to do it like this:
For i = 2 To k Step 2
For j = 4 To k Step 2
If i = j Then
j = j + 2
If array1(i) = "" Then
j = 30 'this is past the end of the array and needs to be more dynamic as the size of the array will be.
myComp = StrComp(array1(i), array2(j), vbTextCompare)
If myComp = 0 Then
array2(j) = ""
array1(j) = ""
Unfortunately, that doesn't work, and I am really not sure why. Doing it this way is not set in stone and if someone knows of a better algorithm to accomplish this that is fine, or if you know how to modify what I have to remove the duplicates that would be great.