|
-
Jan 30th, 2007, 04:58 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] VB code running very slowly....any ideas?
When I start my application it downloads a bunch of data and slots it into listboxes and combo boxes. The main form has five tabs: head of, distributor, site, team, and parent company. Each of those five tabs has two listboxes and the data is pre-loaded into every one of those before the form is even displayed.
The problem I'm having is when the user changes from one tab to another. The code used to run very quickly, but I changed the way I connect to the database (at the request of the DBAs) and now create a new ADO connection when I need to access the DB and destroy it as soon as I'm done.
Switching between tabs does not need an ADO connection since the data is pre-loaded, but ever since I made this change that action has been very slow. Switching from one tab to another now takes 1-2 seconds which I think is too long. I can't figure out why it would take so long just looking at the code that's there. I put in breakpoints earlier and tested it; that is all that's being executed when the user goes from tab to tab. I'm scratching my head here.
This is the code that is executed when the user goes from one tab to another:
VB Code:
Public Sub ClearGlobals()
' Clears app variables
appActiveTab = ""
appPrimInfoValue = ""
appReportSelected = ""
appAddInfoValue = ""
appAddInfoType = ""
End Sub
VB Code:
Public Sub SetActiveTab()
appActiveTab = GetActiveTabName()
End Sub
VB Code:
Public Sub ResetLists()
' Sets selections to false, i.e. if a value is selected on one
' tab, switching from one tab to another causes it to be de-selected
With CriteriaSelection
.lstHeadOf.Text = ""
.lstHeadOfReport.Text = ""
.lstDist.Text = ""
.lstDistReport.Text = ""
.lstSite.Text = ""
.lstSiteReport.Text = ""
.lstTeamReport.Text = ""
.lstParentCompany.Text = ""
.lstPCompReport.Text = ""
.SubFilter.Text = ""
.SubFilterContents.Text = ""
End With
End Sub
Code for GetActiveTabName():
VB Code:
Public Function GetActiveTabName() As String
Select Case GetActiveTabNumber()
Case Is = 0
GetActiveTabName = "HeadOf"
Case Is = 1
GetActiveTabName = "Distributor"
Case Is = 2
GetActiveTabName = "Site"
Case Is = 3
GetActiveTabName = "Team"
Case Is = 4
GetActiveTabName = "Parent"
Case Else
GetActiveTabName = ""
End Select
End Function
-
Jan 30th, 2007, 07:51 AM
#2
Re: VB code running very slowly....any ideas?
How was data transferred to the listboxes/comboboxes? Are you using data bound listboxes/comboboxes?
-
Jan 30th, 2007, 08:15 AM
#3
Thread Starter
Hyperactive Member
Re: VB code running very slowly....any ideas?
 Originally Posted by leinad31
How was data transferred to the listboxes/comboboxes? Are you using data bound listboxes/comboboxes?
They're loaded through code; they're not data bound.
-
Jan 30th, 2007, 08:26 AM
#4
Re: VB code running very slowly....any ideas?
When you run it with breakpoints, does it run normally or is there anything running slow in it? I mean like putting the breakpoint as soon as the tab is clicked, then keep pressing F8 until you get to a point where its a bit slow.
-
Jan 30th, 2007, 08:32 AM
#5
Re: VB code running very slowly....any ideas?
"The problem I'm having is when the user changes from one tab to another. The code used to run very quickly, but I changed the way I connect to the database (at the request of the DBAs) and now create a new ADO connection when I need to access the DB and destroy it as soon as I'm done."
If that was the only change then check if connection or ADO related code is being run during tab switch (relevant events of contained controls included such as _Change() if being "reset", not just tab events)
-
Jan 30th, 2007, 08:47 AM
#6
Thread Starter
Hyperactive Member
Re: VB code running very slowly....any ideas?
 Originally Posted by Andrew G
When you run it with breakpoints, does it run normally or is there anything running slow in it? I mean like putting the breakpoint as soon as the tab is clicked, then keep pressing F8 until you get to a point where its a bit slow.
I didn't do that because I didn't know how.
Now that I've done it I know exactly what the problem is but not how to fix it.
The problem is that when the user goes from tab to tab the variables that held his selections (what report, what site, etc.) are cleared but they still appear to be selected on the tabs. How do I clear those selections in the listbox without using listbox.text?
-
Jan 30th, 2007, 08:54 AM
#7
Re: VB code running very slowly....any ideas?
-
Jan 30th, 2007, 08:56 AM
#8
Thread Starter
Hyperactive Member
Re: VB code running very slowly....any ideas?
 Originally Posted by leinad31
listbox.listindex = -1
HAHAHAHAHA funny you should say that, I googled around and that's precisely what I was about to try.
-
Jan 30th, 2007, 09:10 AM
#9
Thread Starter
Hyperactive Member
Re: VB code running very slowly....any ideas?
 Originally Posted by leinad31
listbox.listindex = -1
That worked...it exposed a bug in my code but it solved the first problem, thanks!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|