?
Solved

Decreasing load/unload time of custom usercontrol

Posted on 2007-07-20
6
Medium Priority
?
636 Views
Last Modified: 2007-08-07
Hi Experts,

I'm currently writing a VB6 usercontrol that consists of 7 textboxes, 2 buttons, 8 labels and a combobox. This control is duplicated into a scrollable box between 1 and 250 times.

The problem is that it's taking a very long time to load and a very long time to unload the usercontrols when there are more than about 20 or so. The load time I can understand, it's probably having to process a lot of information, but is there anything I can do to make the items unload any faster?

Any ideas much appreciated.

Many thanks,

Rob
0
Comment
Question by:Bobeo
  • 3
  • 2
6 Comments
 
LVL 38

Expert Comment

by:PaulHews
ID: 19535651
>This control is duplicated into a scrollable box between 1 and 250 times.

If you make your usercontrol data bound, you can take advantage of the datarepeater control.  It's very much like what you are describing, and is optimized for this kind of thing.  There's a good example in the help under "Using the DataRepeater Control"
0
 
LVL 3

Author Comment

by:Bobeo
ID: 19536062
Cheers for your response.

The data currently exists in class modules which link with an XML file. Is there an easy way to convert this structure to and from OLEDB? What would the overheads be? I need to make this as easy to distribute as possible.
0
 
LVL 38

Expert Comment

by:PaulHews
ID: 19536361
>Is there an easy way to convert this structure to and from OLEDB?
Creating a disconnected recordset object can be done this way:

Option Explicit

Private Sub Command1_Click()
    Dim rs As ADODB.Recordset
   
    Set rs = New ADODB.Recordset
    rs.Fields.Append "FirstName", adVarChar, 20
    rs.Fields.Append "LastName", adVarChar, 20
    rs.CursorLocation = adUseClient
    rs.CursorType = adOpenStatic
    Dim Fields As Variant
    Fields = Array("FirstName", "LastName")
   
   
    rs.Open
    rs.AddNew Fields, Array("Jim", "Murphy")
    rs.AddNew Fields, Array("Devon", "Oakley")
    rs.AddNew Fields, Array("Michael", "Wells")

End Sub

The recordset is an object that can be used as a data source for the ADO data control.  

AddNew can be called different ways.  Just a matter of looking at the docs.

You can loop through and read out the information:

rs.MoveFirst
Dim i As Integer
For i = 1 To rs.RecordCount
    Debug.Print rs("FirstName").Value
    rs.MoveNext
Next
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 3

Author Comment

by:Bobeo
ID: 19539883
Thanks for the info. I've had a look through and with my application being as huge as it is already I'm a bit concerned about having to distribute ADO controls, as well as creating another ActiveX OCX. As you can probably tell, I'm trying to keep it as dependancy free as possible!

Do you have any other thoughts on speeding up the loading and unloading of my existing control?
0
 
LVL 2

Accepted Solution

by:
kevinfigg earned 2000 total points
ID: 19543637
Hide the controls on the form until they are loaded. The same with the unloading. Hide them, then execute the unload. If you have control of the form, you could also hide that until they are loaded, but this may be a little un-necessary.

Even by hiding the controls the user will get the impression it is quicker - which is the only thing you need to worry about.

You might also consider moving all the text boxes in the control to a control array. This will speed up the process no-end. However, this will probably mean quite a substationial re-write.
0
 
LVL 3

Author Comment

by:Bobeo
ID: 19650083
Sorry for forgetting this question. Bad practice!

Cheers for your help Kevin. Hiding the controls did save a bit of time, as did adding the text control to a control array.

Nobody seems to have any better ideas so the points are yours!

Cheers!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month13 days, 20 hours left to enroll

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question