Check if a record exists in a VB6 collection?

前端 未结 9 1429
失恋的感觉
失恋的感觉 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 11:02

    Using the error handler to catch cases when the key does not exists in the Collection can make debugging with "break on all errors" option quite annoying. To avoid unwanted errors I quite often create a class which has the stored objects in a Collection and all keys in a Dictionary. Dictionary has exists(key) -function so I can call that before trying to get an object from the collection. You can only store strings in a Dictionary, so a Collection is still needed if you need to store objects.

提交回复
热议问题