Key Property

       

Returns or sets a string that uniquely identifies a member in a collection.

Syntax

object.Key [= string]

The Key property syntax has these parts:

Part Description
object Required. An object expression that evaluates to an object in the Applies To list.
string A unique string identifying a member in a collection.

 

Remarks

If the string is not unique, an error will occur.

You can set the Key property when you use the Add method to add an object to a collection.

If you expect the Index property to change dynamically, refer to objects in a collection using the Key property.

In addition, you can use the Key property to make your Visual Basic project "self-documenting" by assigning meaningful names to the objects in a collection.