Alright...so I'm going to be doing some speed testing!
Whatever Dugor saidIt's faster to do "If IsNumeric(Check) Then Check = CInt(Check)" than Check = Val(Check). So don't use Val()!
If statements versus Select CaseSelect Case is twice as fast as If statements. (If statements were almost 4000ms and select case was 1600ms)
Not versus =FalseIf Not Check Then is faster than If Check = False Then.
Long versus all other numerical data typesLong is the fastest variable to use in a loop compared to bytes, integers, singles, doubles, and currency.
Byte versus BooleanYou think If Blah = 1 Then is faster than If Blah = True Then? WRONG! Boolean comparison is faster than byte comparison
If Check versus If Check = TrueIf Check Then is faster than If Check = True Then.
Comparing Longs, Integers, Bytes, and StringsIt's fastest to compare Longs, Integers is second fastest, Bytes is third, and Strings are the slowest to compare. With 10 million cycles they all did around 1 second and weren't really that much faster than the other (about 100 ms), but strings did almost 2 seconds...
=True versus =1=True appears to be faster than =1! With 10 million cycles =True did about half a second and =1 did 1 second.
<1 Versus =0Unfortunately, doing <1 and =0 will result in the same speed. No gain or loss on either side.
Val() versus CByte/CInt/CLngI just did a Val() versus CByte/CInt/CLng! With 10 million cycles Val() took about 10 seconds and the proper Conversion functions took less than a second for each.
CByte was fastest, CLng was second fastest, and CInt was the slowest of the three.
If checks versus AndI did 10 If checks and then I did 10 checks with And. I did this with a 10 million cycle and the And took about 18 seconds and the If took 10 seconds.
RECOMMEND MORE TESTS!
_________________
Nean wrote:
Yes harold. Give it to me.