I got the idea to test out how fast different loop structures in VB are from thread796-425375. I Tested the if elseif contruct against the select case construct.
I looped through a form with 8 different controls on it 10,000 times and ran it thru each construct respectively.
I did 20 sets of this and 3 trials The totals that I got are. The numbers are measured in clock ticks
Total
Select Case/For Each: 6549479
Select Case/For Next: 6460937.6
If ElseIf/For Each: 14929687.6
If ElseIf/For Next: 18744791.3
Select Case is 2.59 X faster than if ElseIf
I also decided to run a For Each against a For Next.
This I ran 1,000,000 times. Once again with 20 sets and 3 trials. The totals that I got are. The numbers are measured in clock ticks.
Total
For Each: 16283854.6
For Next: 4653645.3
For Next is 3.50 X faster than For Each
For the results I got you can see that it is benificial to use Selects and For Next statments whenever possible. That'l do donkey, that'l do
Mark
If you are unsure of forum etiquette check here faq796-2540
I looped through a form with 8 different controls on it 10,000 times and ran it thru each construct respectively.
I did 20 sets of this and 3 trials The totals that I got are. The numbers are measured in clock ticks
Total
Select Case/For Each: 6549479
Select Case/For Next: 6460937.6
If ElseIf/For Each: 14929687.6
If ElseIf/For Next: 18744791.3
Select Case is 2.59 X faster than if ElseIf
I also decided to run a For Each against a For Next.
This I ran 1,000,000 times. Once again with 20 sets and 3 trials. The totals that I got are. The numbers are measured in clock ticks.
Total
For Each: 16283854.6
For Next: 4653645.3
For Next is 3.50 X faster than For Each
For the results I got you can see that it is benificial to use Selects and For Next statments whenever possible. That'l do donkey, that'l do
Mark
If you are unsure of forum etiquette check here faq796-2540