Collection.Add

From Real Software Documentation

Jump to: navigation, search
Method
Collection.Add ( Value as Variant [,Key as String] )

Adds Value as the last element of the collection.

Notes

If Key is provided, it may be used to refer to the element using the Item property. Key defaults to the empty string.

Example

The following example creates a collection, populates it with both string and numeric values, and displays each element in TextFields or a Canvas control (The picture "lois" has been added to the project). Note that a collection is much like a database record.

Dim c as New Collection
c.add 1,"ID"
c.add "Lois Lane", "Name"
c.add "Reporter", "JobTitle"
c.add 85000,"Salary"
c.add lois,"Picture"
TextField1.text=c.item("ID")
TextField2.text=c.item(2) //returns "Lois Lane"
TextField3.text=c.item("JobTitle")
TextField4.text=c.item("Salary")
Canvas1.backdrop=c.item("Picture")
Personal tools