COMPOBJ( ) Function Example

In the following example, two ListBoxes named lstMyList1 and lstMyList2 and a ComboBox named cmbMyCombo are created. The Name property of each ListBox is displayed.

COMPOBJ( ) is used to compare the properties of the first ListBox with the properties of the ComboBox. Because many of the properties are different, .F. is displayed. COMPOBJ( ) is then used to compare the properties of the first ListBox with the properties of the second ListBox. Because the Names properties are different, .T. is displayed. The second ListBox lstMyList2 is replaced with the first ListBox lstMyList1, and COMPOBJ( ) is used to compare the properties. Because their properties are identical, .T. is displayed.

lstMyList1 = CREATEOBJ('ListBox')  && Creates a ListBox
lstMyList2 = CREATEOBJ('ListBox')  && Creates a second ListBox
cmbMyCombo = CREATEOBJ('ComboBox')  && Creates a ComboBox

CLEAR
? lstMyList1.Name  && Displays List1 Name property
? lstMyList2.Name  && Displays List2 Name property

? COMPOBJ(lstMyList1, cmbMyCombo)     && Displays .F.
? COMPOBJ(lstMyList1, lstMyList2)     && Displays .F., different Names
lstMyList2.Name = lstMyList1.Name
? COMPOBJ(lstMyList1, lstMyList2)     && Displays .T., same properties