PlanetSquires Forums

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Best practice to re-use combo box string values  (Read 238 times)

Jean-Pierre LEROY

  • Guest
Best practice to re-use combo box string values
« on: April 18, 2007, 12:28:43 PM »

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.
Logged

TechSupport

  • Guest
Re: Best practice to re-use combo box string values
« Reply #1 on: April 18, 2007, 12:54:54 PM »

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:
Code: [Select]
%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


Logged

Jean-Pierre LEROY

  • Guest
Re: Best practice to re-use combo box string values
« Reply #2 on: April 18, 2007, 02:07:26 PM »

Thank you very much Paul for your prompt reply.

It's exactly what I was looking for.
Logged