Bobeo
asked on
Decreasing load/unload time of custom usercontrol
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
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
ASKER
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.
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.
>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
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
ASKER
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?
Do you have any other thoughts on speeding up the loading and unloading of my existing control?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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!
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!
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"