Search code examples
vb6

How to check the key is exists in collection or not


I want to check collection variable contains the key or not in visual basic 6.0 Below is the collection variable I am having

pcolFields As Collection

and I want to check whether it contains the field Event_Code. I am doing this as below but it not worked for me.

    If IsMissing(pcolFields("Event_Code")) = False Then
        'Do Something
    End If

Solution

  • We can check following code into vb.net code

    If Collection.ContainsKey(KeyString) Then

    'write code

    End if

    Collection is variable of Dictionary and KeyString is a key string which we need to find into collection