Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add Combo Box in a Faster Way!?

Status
Not open for further replies.

skyplayer

Programmer
Joined
May 28, 2002
Messages
13
Location
HK
How to increase the speed of adding items to a combo box?
The original code is as below:
===============================================
//n = 11600, a is an array with n elements
For i = 1 to n
cboCombo.additem a(i)
next
===============================================
It takes about 15s to add 11600 item in a combo box
I would like to ask a faster way to do it!Thx
 
There isn't a faster way in VB6, unfortunately. I tried your way and
For i = N to 1 Step -1
cboCombo.additem a(i), 0
next

Your way = 6 seconds,
My way = 22 seconds.
Generate Forms/Controls Resizing/Tabbing Class
Compare Code (Text)
Generate Sort Class in VB or VBScript
 
If you are prepared to use the combobox from the Microsoft Form 2.0 object library, then you can directly assign the array to the combobox:
[tt]
ComboBox1.List = a
[/tt]
which is a lot faster.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top