mari_carmen
asked on
Removing duplicate data from an array
The code below displays job numbers.
CompleteJobs.JobNum2(K).Te xt = TempJobs2(M)
K = K + 1
M = M + 1
Loop Until TempJobs2(M) = Empty
The problem is duplicate numbers are displayed. How can i remove the duplicate job numbers when displaying.
CompleteJobs.JobNum2(K).Te
K = K + 1
M = M + 1
Loop Until TempJobs2(M) = Empty
The problem is duplicate numbers are displayed. How can i remove the duplicate job numbers when displaying.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
c'mon boys.... mari_carmen is only with us since 13 June. I've heard that some new people did not get the customary 200 points to start with. If mari_carmen is one of those unfortunates, it would add up to (16 days) 80 points or thereabouts. No wonder mari_carmen has only got 25 points to spare...
mari_carmen, did you get your 200 points when you started (don't lie because Mirkwood has ways and means of checking... :o)
mari_carmen, did you get your 200 points when you started (don't lie because Mirkwood has ways and means of checking... :o)
What I'd do with an array to remove dupes is this:
Dim aCol as New Collection
On Error Resume Next
Dim i As Long
For i = LBound(TempJobs2) to UBound(TempJobs2)
aCol.Add TempJobs2(i), "k" & i
Next i
For i = 1 To aCol.Count
CompleteJobs.JobNum2(i).Te xt = aCol(i)
Next i
Set aCol = Nothing
It seems a bit simpler than waty's solution to me. Admittedly, it does use more memory than waty's suggestion, but it seems to me that the simplest way is often the best.
And I can't remember if Collections are 1 based or 0 based. If they are 0 based, then the For line should read:
For i = 0 to aCol.Count - 1
And that's it.
J.
Dim aCol as New Collection
On Error Resume Next
Dim i As Long
For i = LBound(TempJobs2) to UBound(TempJobs2)
aCol.Add TempJobs2(i), "k" & i
Next i
For i = 1 To aCol.Count
CompleteJobs.JobNum2(i).Te
Next i
Set aCol = Nothing
It seems a bit simpler than waty's solution to me. Admittedly, it does use more memory than waty's suggestion, but it seems to me that the simplest way is often the best.
And I can't remember if Collections are 1 based or 0 based. If they are 0 based, then the For line should read:
For i = 0 to aCol.Count - 1
And that's it.
J.
Collections are 1-based.
"It is up to you to assign points to the question based on its difficulty. As a guide, a basic question is worth 50 points, an intermediate question 100 points, and an advanced question 200 points. The more points assigned to a question, the more likely it will be answered."