How to Store Numeric Values that Come from a Combo BoxLast reviewed: November 14, 1995Article ID: Q139214 |
The information in this article applies to:
SUMMARYWhen the ControlSource property of a combo box or list box evaluates to a numeric variable and the list box displays numeric data, the ControlSource stores the index number (position) in the list, not the data that is displayed. This article shows by example how to store the numeric value listed in a combo box in a numeric variable.
MORE INFORMATIONThe RowSource property of a combo box or list box specifies the source of the values; that is, it indicates where the data is coming from. The ControlSource property of a combo box specifies the data that is modified when a selection is made. It indicates where the data is going to. When a combo box is bound to a character variable, the expression displayed in the list is stored to the ControlSource. When the object is bound to a numeric variable, the index order of the expression is stored to the ControlSource. For example, say the list displays the following elements:
------ | 10 | | 20 | | 30 | | 40 | ------If the number 30 is selected when the data is bound to a numeric variable, the variable stored in the ControlSource property will evaluate to 3, because 30 is the third element in the list. If the data originates from a table, this index can correspond to a record number. When a combo box or a list box is not bound to any data, ControlSource is empty. The Value property stores the character string that is currently selected. Using the previous example, the Value property is equal to 30 if the list box is not bound to data. The Visual FoxPro Help file indicates that once the ControlSource property is set to a field or variable, the Value property always has the same data value and the same data type as the variable or field to which the ControlSource property is set. To store the numeric selection of a combo box to a numeric variable, you can assign the value of the combo box to the variable in the Interactive Change event handler. This assumes that the object is not bound to data. The following step-by-step example illustrates this procedure.
Step-by-Step Example
|
Additional reference words: 3.00 combobox listbox
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |