Property Parameters

The CDO libraries interface with the Microsoft® Visual Basic® library and with the IDispatch interface. These interfaces define only methods and no properties. In order to expose properties on its objects, CDO implements all properties with accessor methods. A read/write property has corresponding get and put methods defined for it. A read-only property has a get method but no put method. For the most part, these accessor methods are transparent to a Visual Basic programmer.

The get and put methods are all defined with optional parameters. These are used by a Visual Basic programmer with properties that have parameterized syntax, such as the Fields property of the Attachment object or the Item property of the Views collection. In most properties other than Fields and Item, the syntax does not make use of any parameters. They can be supplied but will be ignored:

stFoldID = obFolder.ID(3, size, "All these parameters are ignored") 
 

Because of the possibility of parameters, parentheses immediately following a property name are always construed to enclose a parameter list.

Array properties pose a special problem in this connection. A programmer intuitively expects to select a particular element of an array by supplying an index immediately after the array name. This works normally when the variable has been dimensioned as an array:

Dim arValues (100) As Integer ' array of 100 integers 
  ' ... 
  sum = 0 
  For i = 1 To 100 
    sum = sum + arValues(i) 
  Next i 
 

But when the variable is a CDO property, the first set of parentheses after its name is taken as holding one or more syntactic parameters. If the property has an array data type, such as the Categories property of the Message object, a second set of parentheses must be added to specify the array index:

stPrincipalCategory = obMessage.Categories()(1) 
 

This applies both when reading an array property and when writing it:

obMessage.Categories()(index) = "" 
 

However, no parentheses are needed if the entire array is participating in an operation, because no index needs to be specified and there is no need for any parentheses at all:

Dim stCategories (10) As String 
  obMessage.Categories = stCategories ' full array copy