Advanced Concepts

Each object has a default property which does not need to be specified. For example, the default property of an EccoFolder object is the folder name. The following are therefore equivalent:

Debug.print MyFolder.Name 
Debug.print MyFolder

There are a couple of important differences in syntax when working with objects. First, when assigning an object to a variable, you must use the Set keyword, as shown in the above examples. Note that this only applies when assigning an object itself to a variable – most object properties are strings, numbers, booleans or date variants that can be assigned using the Let keyword, which, of course, can be omitted. (See, for example, the first line in the preceding example.)

Another difference is in testing for equality. Concepts such as greater than or less than have no meaning when objects are involved. Equality would mean that the variables in fact refer to the same object. This is done using the Is keyword, rather than the equal sign. For example:

Set MyItem = MyOldItem 
If MyItem Is MyOldItem Then Stop 

The above will, of course, execute the Stop statement.

Note that the Is keyword can only tell whether the objects are the same, and not whether the objects represent the same data. The following example will never encounter the Stop statement:

Set MyItem1 = MyFolder.Items("Heindl, Walter") 
Set MyItem2 = MyEcco.Items("Heindl, Walter") 
If MyItem1 Is MyItem2 Then Stop 

In order to determine whether two objects represent the same Ecco data, you should compare the ID property. Ecco folders and items each are identified uniquely by an integer, represented by the ID property. For example:

If MyItem1.ID = MyItem2.ID Then Stop

Another difference is in how to clear object variables. To clear an integer you assign it a value of zero. To clear a string you assign the null string. To clear an object variable you assign it the Nothing keyword. For example:

Set MyItem = Nothing 

Note that this only clears the MyItem variable. It does not delete data from the Ecco file!

It is good practice to set all object variables to Nothing before exiting your program.  Moreover, it is essential that your program set the EccoApp object variable to Nothing before it exits.  Otherwise, VBECCO.EXE will remain loaded in memory.