VB检测数组中的重复元素

前端之家收集整理的这篇文章主要介绍了VB检测数组中的重复元素前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
'需要点击菜单:工程->引用->MicrosoftScriptingRuntime
Public Function HasRepeat(ByRef arr() As String) As Boolean
    Dim dict As Dictionary
    Set dict = New Dictionary
    Dim i As Variant
    For Each i In arr
        If i <> "" Then
            If dict.Exists(i) Then
                HasRepeat = True
                Exit Function
            Else
                dict.Add i,0
            End If
        End If
    Next
    HasRepeat = False
End Function

猜你在找的VB相关文章