fjerne dubletter i array
Skal have fjernet dubletter i et array bestående af navne, som bliver hentet i en .txt fil. Fandt et stykke kode i et andet spørgsmål, men det virker ikke rigtigt. Den fjerne ikke rigtigt dubletterne.Her er min kode:
countForArray = 0
Set fs = Server.CreateObject("Scripting.FileSystemObject")
Set f = fs.OpenTextFile(Server.MapPath("dkpfiles\"& fileNameArray(1)), 1)
Do While f.AtEndOfStream = False
joinArray = Split(f.ReadLine, ",")
If countForArray = 0 Then
newJoinArray = newJoinArray & joinArray(0)
Else
newJoinArray = newJoinArray &","& joinArray(0)
End If
countForArray = countForArray + 1
Loop
newJoinArray = Split(newJoinArray, ",")
Redim cleanJoinArray(0)
cleanJoinArray(0) = newJoinArray(0)
For i = LBound(newJoinArray) To UBound(newJoinArray)
insertOK = True
For n = LBound(cleanJoinArray) To UBound(cleanJoinArray)
If cleanJoinArray(n) = newJoinArray(i) Then
insertOK = False
Exit For
End If
Next
If insertOK = True Then
Redim Preserve cleanJoinArray(UBound(cleanJoinArray) + 1)
cleanJoinArray(UBound(cleanJoinArray)) = newJoinArray(i)
End If
Next
For j = LBound(cleanJoinArray) To UBound(cleanJoinArray)
... indhold her ...
På forhånd tak!