Which is faster, an if statement or making something = something else?
Okay, I know you are confused. Let me be more specific and we'll see if it helps.
Loop start
If X = False Then X = True (((((OR)))))) X = True
Loop end
With "If X = False Then X = True" it would only make it true once, which seems like it would save time because it wouldn't set X to true every time. But with "X = True" it would just go right ahead and make it true every time, which would seem to save time not having to check to see if X was equal to false every time. So, which one is faster? Checking to see if X = False, or making X = True?
Re: Which is faster, an if statement or making something = something else?
Quote:
Originally posted by krah
Okay, I know you are confused. Let me be more specific and we'll see if it helps.
Loop start
If X = False Then X = True (((((OR)))))) X = True
Loop end
With "If X = False Then X = True" it would only make it true once, which seems like it would save time because it wouldn't set X to true every time. But with "X = True" it would just go right ahead and make it true every time, which would seem to save time not having to check to see if X was equal to false every time. So, which one is faster? Checking to see if X = False, or making X = True?
Something i'm wondering though...If you only check for one thing, then after you find it, shouldn't you break out of the loop? If its a For...Next loop then use Exit For. Not sure about the other loops. Just a thought.:)