20-09-2008, 06:14 PM
Alright...so I'm going to be doing some speed testing!
Whatever Dugor said
It's faster to do "If IsNumeric(Check) Then Check = CInt(Check)" than Check = Val(Check). So don't use Val()!
If statements versus Select Case
Select Case is twice as fast as If statements. (If statements were almost 4000ms and select case was 1600ms)
Not versus =False
If Not Check Then is faster than If Check = False Then.
Long versus all other numerical data types
Long is the fastest variable to use in a loop compared to bytes, integers, singles, doubles, and currency.
Byte versus Boolean
You 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 = True
If Check Then is faster than If Check = True Then.
Comparing Longs, Integers, Bytes, and Strings
It'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.
[size=150]
Whatever Dugor said
It's faster to do "If IsNumeric(Check) Then Check = CInt(Check)" than Check = Val(Check). So don't use Val()!
If statements versus Select Case
Select Case is twice as fast as If statements. (If statements were almost 4000ms and select case was 1600ms)
Not versus =False
If Not Check Then is faster than If Check = False Then.
Long versus all other numerical data types
Long is the fastest variable to use in a loop compared to bytes, integers, singles, doubles, and currency.
Byte versus Boolean
You 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 = True
If Check Then is faster than If Check = True Then.
Comparing Longs, Integers, Bytes, and Strings
It'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.
[size=150]