Advertisement
eldiegotee

Untitled

Jan 12th, 2023
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. Public Function BorrarRepetidos() As Long
  2.  
  3. ' -- Variables
  4. Dim i As Long
  5.  
  6. Dim j As Long
  7.  
  8. Dim Ret As Long ' -- total de items que se eliminan
  9.  
  10. With frmProcessList.List1
  11.  
  12. ' -- Recorrer todos los items
  13. For i = 1 To .ListCount '.ListItems.Count
  14.  
  15. ' -- Comparar uno a uno con todos los demás
  16. For j = i + 1 To .ListCount
  17.  
  18. 'If .ListItems.Item(i) = .ListItems.Item(j) Then
  19. If .List(i) = .List(j) Then
  20. ' -- Si es igual eliminar
  21. .RemoveItem j
  22. j = j - 1
  23. Ret = Ret + 1
  24. End If
  25.  
  26. If j = .ListCount Then
  27.  
  28. Exit For
  29.  
  30. End If
  31.  
  32. Next
  33.  
  34. If i = .ListCount Then
  35. BorrarRepetidos = Ret
  36.  
  37. Exit Function
  38.  
  39. End If
  40.  
  41. Next
  42.  
  43. End With
  44.  
  45. End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement