...
FOR I =0 TO ....
If Not MYDIC.EXISTS(COLB) Then
CCODART.AddItem UCase(COLB)
Else
MYDIC.Add UCase(COLB), I
End If
NEXT I
...
Is this a corrct code to fill the combobox with unique value?
FILL COMBOBOX WITH DICTIONARY
-
- Administrator
- Posts: 78412
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: FILL COMBOBOX WITH DICTIONARY
I think you should use
Alternatively, fill the dictionary first, the populate the combo box with the keys of the dictionary:
Code: Select all
FOR I = 0 TO ....
If Not MYDIC.EXISTS(UCase(COLB)) Then
CCODART.AddItem UCase(COLB)
MYDIC.Add UCase(COLB), 1
End If
NEXT I
Code: Select all
FOR I = 0 TO ....
MYDIC.Add UCase(COLB), 1
NEXT I
CCODART.List = MYDIC.Keys
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 4351
- Joined: 26 Apr 2010, 17:36
Re: FILL COMBOBOX WITH DICTIONARY
based to limit the time, first or second option?HansV wrote: ↑24 Feb 2021, 17:20I think you should use
Alternatively, fill the dictionary first, the populate the combo box with the keys of the dictionary:Code: Select all
FOR I = 0 TO .... If Not MYDIC.EXISTS(UCase(COLB)) Then CCODART.AddItem UCase(COLB) MYDIC.Add UCase(COLB), 1 End If NEXT I
Code: Select all
FOR I = 0 TO .... MYDIC.Add UCase(COLB), 1 NEXT I CCODART.List = MYDIC.Keys
-
- Administrator
- Posts: 78412
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: FILL COMBOBOX WITH DICTIONARY
I think the second one is faster, but you won't notice it unless you are processing hundreds of thousands of records.
Best wishes,
Hans
Hans