我正在为包含字符串的vb6集合编写一个Contains方法。
但是我无法在我的foreach上获得正确的语法。
我应该改变什么?
答案 0 :(得分:3)
Public Function Contains(col as Collection, key as Variant) as Boolean
Dim thing as Object '// this is the key
For Each thing in col
If CStr(key) = CStr(thing) then
Contains = True
Exit Function
End If
Next
Contains = False
End Function