Best practice to re-use combo box string values

Started by Jean-Pierre LEROY, April 18, 2007, 12:58:43 PM

Previous topic - Next topic

Jean-Pierre LEROY

Hello,

I use the same combo box on various form in the same project; is-there any "best practice" to re-use the combo-box string values ? what's the best solution :

1. to store string values in string equates ?
2. to store string values in string arrays ?
3. any other solution ?

Thank for your help.
Jean-Pierre.

TechSupport

I would think that global arrays would be the easiest to maintain and use. You could have one array for each combobox.

If you want to get fancy then you could use one global array for all comboboxes. Each element in that array would correspond to a different combobox. You would delimit the individual items by a special character and then ParseCount/Parse it when loading the combobox.

For example:

%COMBO_CUSTOMERS = 0
%COMBO_VENDORS = 1
%COMBO_EMPLOYEES = 2
%COMBO_GOVERNMENT = 3

Global AllCombos( 3 ) As String

AllCombos(%COMBO_CUSTOMERS) = "Option1|Option2|Option3|Option4"  'etc...
AllCombos(%COMBO_VENDORS) = "Option1|Option2|Option3|Option4"  'etc...
AllCombos(%COMBO_EMPLOYEES) = "Option1|Option2|Option3|Option4"  'etc...
AllCombos(%COMBO_GOVERNMENT)= "Option1|Option2|Option3|Option4"  'etc...

' Load the combobox...
nItems = ParseCount( AllCombos(%COMBO_VENDORS), "|" )

For x = 1 To nItems
   FF_ComboBox_AddItem hWndControl, Parse$(AllCombos(%COMBO_VENDORS), "|", x )
Next



Jean-Pierre LEROY

Thank you very much Paul for your prompt reply.

It's exactly what I was looking for.