Collections

In COM, objects of the same type are often grouped into special objects called collections. For example, Microsoft Excel has a Workbooks object, which is a collection of all of the open workbooks in the application.

In many development tools such as Visual Basic, items in a collection can be accessed directly using the standard subscript notation. You do not need to use an additional property or method to access the items in a collection. You can just use the collection as the method or property to retrieve the item. For example, the following Visual Basic code retrieves the first item from the Fields collection of an ADO recordset.

{Visual Basic code to retrieve a field from a recordset.}
local ADODB.Field dbField;
dbField = recordset.Fields(1);

You cannot directly access the values of a collection from sanScript. Instead, you must use additional properties and methods to access the items in a collection. Often the Item method or the Item property can be used to access the items in a collection. For example, the following sanScript code retrieves the first item from the Fields collection of an ADO recordset. Notice that the Item property must be used to access the item in the collection.

{sanScript code to retrieve a field from a recordset.}
local ADODB.Field dbField;
dbField = recordset.Fields.Item[1];

In many cases, the Item method or property is hidden, so it won’t be visible in the Class Browser window until you mark the Show Hidden option.



Documentation Feedback