From Xojo Documentation

Revision as of 18:56, 19 November 2009 by WikiSysop (talk) (1 revision)
(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!


Stores key-value pairs.

Super Class



Name Type Description
Left Variant The left value of the pair.
Right Variant The right value of the pair.


Name Parameters Description
Pair Left as Variant,

Right as Variant

Creates a Pair instance that is populated by the passed values.


Use the [[:|:]] operator to assign the Left and Right values of a single Pair in a Dim statement. For example:

Dim p as Pair = 1 [[:|:]] 2

This statement assigns the "1" to the Left property and the "2" to the Right property.

The following is also acceptable:

Dim p as New Pair(1,2)

The values of the Left and Right properties cannot be assigned using the = operator. For example, the code:

Dim p as Pair = 1 [[:|:]] 2

produces a Cannot assign a Value to this Property error.


This example creates a Pair instance and displays its Left and Right properties:

Dim p as Pair = 5 [[:|:]] 6
MsgBox p.Left.StringValue+", "+p.Right.StringValue

This example uses an array of Pairs to obtain a class instance's properties and values using the Introspection system:

Dim tcp as New TCPSocket
Dim ti as Introspection.TypeInfo = Introspection.GetType( tcp )

Dim props() as Pair
For Each prop as Introspection.PropertyInfo in ti.GetProperties
props.Append( prop.Name : prop.Value(tcp ) )
Next prop

The following code displays the Name/Value pairs that were obtained in the previous example in a two-column ListBox:

For Each p as Pair in props
Listbox1.Addrow p.left.Stringvalue
//ignore the problem
End Try
Next p

Creating a liked list:

Dim p as Pair =1 [[:|:]] 2 [[:|:]] 3 [[:|:]] 4

The Left property of the first pair will contain the "1" and the right property will contain the second pair. The second pair's Left property will contain the "2" and its Right property will contain the third pair, and so forth. This statement will produce four linked pairs.

See Also

Dictionary class; : operator.