![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/4568e8eb6c77f16b33b4b6298af0711b.gif)
本贴将展示两种从数组中删除重复项的方法。
第一种方法使用字典,第二种方法使用集合。每种方法都有优点和缺点,但都能很好地返回数组中的独特元素。
一. Dictionary方法删除重复项
注:
- 必须添加对 MicrosoftScripting Runtime library 的引用;
- 本函数中使用了前期绑定(前期绑定能大大提高性能);
- 字典方法在Mac OS系统中不起作用*.*
Function RemoveDupesDict(MyArray As Variant) As Variant
Dim i As Long