VB School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a VB Expert!

Join 300,360 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 1,739 people online right now. Registration is fast and FREE... Join Now!




Improving loading time of form data

 

Improving loading time of form data

PMagor

2 Jul, 2009 - 05:36 AM
Post #1

New D.I.C Head
*

Joined: 2 Jul, 2009
Posts: 3

Hi all,

Sorry if this is a dumb question, but it's been around 10 years since I did any VB programming so I'm extremely rusty. smile.gif

One of my team created an Excel doc before he left the company which used VB6 (v6.5.1020). It uses forms to collect data and store text box, radio button, tick box data, etc into a separate sheet that we can use in other documents. For ease of viewing we also re-load any saved data back into the form if it is opened, and this is where my problem comes.

Whenever we try to open a form with around 150 different pieces of data it takes roughly one minute before the form is displayed. Ideally we'd like to cut down the load times to around 10-15 seconds or less. You can see the code below:

CODE
Dim gettag As String
Dim tagexists As Boolean

For Each Control In Me.Controls
    If TypeName(Control) = "TextBox" Or TypeName(Control) = "OptionButton" Or TypeName(Control) = "CheckBox" Then
        gettag = Control.Tag
        On Error Resume Next
        tagexists = Len(ThisWorkbook.Names(gettag).Name)
        If tagexists = gettag Then
            Control.Value = Sheets("Information").Range(gettag)
        End If
    End If
Next


Is there anything obvious that I'm missing with this?

Thanks for your help in advance!

Paul

User is offlineProfile CardPM
+Quote Post


MajorWalrus

RE: Improving Loading Time Of Form Data

2 Jul, 2009 - 07:34 AM
Post #2

D.I.C Head
**

Joined: 22 Apr, 2009
Posts: 97



Thanked: 9 times
My Contributions
I'm not that surprised its taken a long time to load. A minute? Longish, but interating through all those controls is an intense task.

My suggestion is that hard code some of the controls that you know will have a value. For instance, if there's, say, a field that is always used - a unique id field, maybe - then code that on its own.

Another suggestion would be to build an array of known control tags and then step through the elements of the array, instead of looking into the properties of each control.
User is offlineProfile CardPM
+Quote Post

PMagor

RE: Improving Loading Time Of Form Data

2 Jul, 2009 - 08:24 AM
Post #3

New D.I.C Head
*

Joined: 2 Jul, 2009
Posts: 3

QUOTE(MajorWalrus @ 2 Jul, 2009 - 07:34 AM) *

I'm not that surprised its taken a long time to load. A minute? Longish, but interating through all those controls is an intense task.

My suggestion is that hard code some of the controls that you know will have a value. For instance, if there's, say, a field that is always used - a unique id field, maybe - then code that on its own.

Another suggestion would be to build an array of known control tags and then step through the elements of the array, instead of looking into the properties of each control.


Thanks MajorWalrus! I'll give these a go and hopefully they'll improve things.
User is offlineProfile CardPM
+Quote Post

MajorWalrus

RE: Improving Loading Time Of Form Data

2 Jul, 2009 - 08:48 AM
Post #4

D.I.C Head
**

Joined: 22 Apr, 2009
Posts: 97



Thanked: 9 times
My Contributions
You're welcome. PM if you need some help with the changes.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/7/09 07:48PM

Live VB Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month