Collection.Item

From Xojo Documentation

Revision as of 20:08, 13 February 2022 by Gperlman (talk | contribs) (Sample Code)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!
Method

Collection.Item(Index as Integer) As Variant

Supported for all project types and targets.

Refers to an element of a collection. Index is 1-based.


Method

Collection.Item(Key as String) As Variant

Supported for all project types and targets.

Refers to an element of a collection by the value of its Key.

Sample Code

The following code displays the elements in the collection using Item.

Var 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") // lois is a Picture added to the project
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")