Performanceproblem in a large loop under XP but not under W2K
- From: "Bastian" <btrompetter@xxxxxxxxxxxxxx>
- Date: 10 Apr 2007 04:07:12 -0700
Hallo
we have a perfomance problem under XP wich didn't exist under Windows
2000.
We use a ListView Control wich updates the MenuItems in the click
event depending on a configuration.
It uses two loops, the inner loop is called 15293 times, in this loop
we use a check to see if the menu control has an index parameter. This
check jumps 2468 times into an errorhandler because some menuitems
didn't have the index parameter. The codes runs under Windows 2000
fast enough that the user can click fast in the listview on different
items, but under Windows XP it takes some seconds to switch between
the listitems. I have isolated the performance problem and want to
know why it runs under Windows 2000 faster.
I call the following function in the click event of the listview:
Code Snippet
Private Sub SetMenü(ByVal vcolMenüs As Collection)
Dim cltX As Control
Dim strName As String
Dim vntRec As Variant
Dim strTmp As String
On Error GoTo ErrorHandler
For Each vntRec In vcolMenüs
strName = Format(FItem(vntRec, 1, vbTab), ">")
strTmp = FItem(vntRec, 1, vbTab)
For Each cltX In Me
If TypeOf cltX Is Menu Then
If gblnIsContolArray(cltX) Then
If Format(cltX.Name, ">") & "(" & cltX.Index & ")" =
strName Then
cltX.Visible = (Format(FItem(vntRec, 2, vbTab), ">")
= "J")
Exit For
End If
Else
If Format(cltX.Name, ">") = strName Then
cltX.Visible = (Format(FItem(vntRec, 2, vbTab), ">")
= "J")
Exit For
End If
End If
End If
Next cltX
Next vntRec
Refresh
Exit Sub
ErrorHandler:
If Err.Number = 387 Then Resume Next
If Err.Number = 343 Then Resume Next ' BUFR 21.02.01 ' Object not
an array
If Err.Number <> 0 Then
goError.PrepareErrorMessage mCstrMODULNAME, "SetMenü",
Err.Number, Err.Description
End If
End Sub
The function to check the index parameter is the following:
Code Snippet
Public Function gblnIsContolArray(ByRef robjControl As Control) As
Boolean
Const CintObjectNotAnArray As Integer = 343
On Error GoTo ErrorHandler
gblnIsContolArray = False
If robjControl.Index >= 0 Then
gblnIsContolArray = True
End If
Exit Function
ErrorHandler:
If Err.Number = CintObjectNotAnArray Then
' Keine Fehlerausgabe
Else
goError.PrepareErrorMessage mCstrMODULNAME, "gblnIsContolArray",
Err.Number, Err.Description
End If
End Function
Is the errorhandling diffrent under Windows XP than under 2000 that
we get this performance problem?
Thanks for help.
Regards
Bastian Trompetter
.
- Prev by Date: Re: ASCII Character Set
- Next by Date: Re: Action On Mouse Cllick
- Previous by thread: ASCII Character Set
- Next by thread: Radio Buttons
- Index(es):