在VB6中为每个循环简单破解

时间:2014-02-05 16:29:31

标签: collections foreach vb6

我正在为包含字符串的vb6集合编写一个Contains方法。

但是我无法在我的foreach上获得正确的语法。

enter image description here

我应该改变什么?

1 个答案:

答案 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