Check Whether a Given Key Exists in a Collection

Check Whether a Given Key Exists in a Collection

It is unfortunate that VB5 does not provide a quick way to check if an item with a certain key exists in a collection. This results in errors if an item with an existing key is added or access is attempted with a key not existing in the collection. Typically, the On Error statement is used to trap such an error. But when working with many collections, this becomes tedious and unattractive.

This function checks to see if a given key exists in a collection.

 Public Function ItemExist(mCol As Collection, Key As String) As Boolean    Dim V as Variant    On Error Resume Next    V = mCol(Key)    If Err.Number = 450 Or Err.Number = 0 Then        ItemExist = True    Else        ItemExist = False    End IfEnd Function


If Err.Number is 450, that means mCol(Key) returns an object not a generic data type. If a customized collection is created, it

Share the Post:
data observability

Data Observability Explained

Data is the lifeblood of any successful business, as it is the driving force behind critical decision-making, insight generation, and strategic development. However, due to its intricate nature, ensuring the

Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular

XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved