Clone Method (INamedValues2 interface)



Returns a NamedValues collection that is an exact copy (except for the ReadOnly property) of this collection.




The object placeholder is an object expression that evaluates to an INamedValues2 interface.



The returned value is an INamedValues2 object.

It is much faster to clone an existing collection than it is to call CoCreateInstance (VC++), call CreateObject (VBScript), or use the New operator (VB). If you need a lot of NamedValues collections and performance is important, it may be best to create only one collection and clone it as many times as necessary.

The returned collection is a copy of the existing collection, in all respects except for the ReadOnly property. This includes the Sorted and Style properties, and any internal effects of the SetSize method. If this collection's Count property is greater than zero, the NamedValue members of the returned collection are copies of the members of this collection.

The ReadOnly property of the returned collection is always false. If you want to duplicate that property as well, you may write code similar to this:

Dim newcoll as INamedValues2
Set newcoll = oldcoll.Clone
if oldcoll.ReadOnly then newcoll.Freeze
Enabling Operational Intelligence