7. How to deal with set objects
The automation object has the same structure as some of its JScript objects. It exposes a variety of methods and properties that we can handle. If you have never contacted Visual Basic, you may not be familiar with the set object. A set is a group of related items. The set is used primarily in Visual Basic to keep track of many things, such as loading a form from your program (a form set) or all the controls in the form (control set).
Visual Basci provides a set class, so you can create your own set. Each item in a set object is defined as a variant, which is a 16-byte data type in Visual Basic. OLE Automation sets even if some are exposed through a standard OLE interface. A set object contains four standard elements:
(1) Colobj.add (item[, key][, before]);
The Add () method adds an item to the set. In addition to the data in the province, you can also use the resulting members from the set to specify a key value. Note here that the last parameter cannot be specified by JScript.
The Count property returns the number of items in the set.
(3) Colobj.item (index)
The item () method utilizes this to retrieve items from the collection.
(4) colobj.remove (index);
The Remove () method removes an item from the set since it was selected.
Sets are similar to arrays, but for the following reasons the reaction set is a better choice:
It is awkward to delete an item from the middle of an array. The Remove () method makes it easy for the user to delete any item in the set, depending on its location in the set or the key of the item.
You do not have to redefine a set object, and in Visual Basic you often change the length of the dynamic array. So this will make the results more clear and the code has a good maintenance.
(3) The use of keys, set objects have very fast retrieval capabilities, and the array is not. Even if you don't know where the item is in the center, you can easily find it by key.
Since we're dealing with automation objects, it's important to be familiar with the set. In the script you will find that you are dealing with them, and you will notice the importance of the item () method as follows:
Colworkorders.item ("W050580"). Priority = 4;