snow-raven
Registered User.
- Local time
- Today, 10:32
- Joined
- Apr 12, 2018
- Messages
- 48
General looping efficiency question for building a collection of controls;
Do you think I'd be more efficient evaluating all of the property tags that I want to add to a collection before moving to the next collection, or would it be more efficient evaluating each tag & adding it to all of the appropriate collections before moving to the next tag?
Example:
Or:
Do you think I'd be more efficient evaluating all of the property tags that I want to add to a collection before moving to the next collection, or would it be more efficient evaluating each tag & adding it to all of the appropriate collections before moving to the next tag?
Example:
Code:
For Each ctl In Me.Controls
If ctl.Tag = "Project" Or ctl.Tag = "Intervals" Or ctl.Tag = "Lab" Or ctl.Tag = "TestSetUp" (etc...) Then
colctlsAll.Add ctl, ctl.Name
End If
If ctl.Tag = "Collar" Or ctl.Tag = "Intervals" Or ctl.Tag = "Lab" Or ctl.Tag = "TestSetUp" (etc...) Then
colctlsNewPrjt.Add ctl, ctl.Name
End If
If ctl.Tag = "Intervals" Or ctl.Tag = "Lab" Or ctl.Tag = "TestSetUp" (etc...) Then
colctlsNoCllr.Add ctl, ctl.Name
End If
Next ctl
Set ctl = Nothing
Or:
Code:
For Each ctl In Me.Controls
If ctl.Tag = "Project" Then
colctlsAll.Add ctl, ctl.Name
End If
If ctl.Tag = "Collar" Then
colctlsAll.Add ctl, ctl.Name
colctlsNewPrjt.Add ctl, ctl.Name
End If
If ctl.Tag = "Intervals" Then
colctlsAll.Add ctl, ctl.Name
colctlsNewPrjt.Add ctl, ctl.Name
colctlsNoCllr.Add ctl, ctl.Name
End If
Next ctl
Set ctl = Nothing