Check if a record exists in a VB6 collection?

前端 未结 9 1428
失恋的感觉
失恋的感觉 2020-12-17 10:20

I\'ve inherited a large VB6 app at my current workplace. I\'m kinda learning VB6 on the job and there are a number of problems I\'m having. The major issue at the moment is

9条回答
  •  不思量自难忘°
    2020-12-17 10:54

    Better solution would be to write a TryGet function. A lot of the time you are going to be checking exists, and then getting the item. Save time by doing it at the same time.

    public Function TryGet(key as string, col as collection) as Variant
      on error goto errhandler
      Set TryGet= col(key)
      exit function
    errhandler:
      Set TryGet = nothing  
    end function
    

提交回复
热议问题