Len() vs empty string

the master
01-06-2008, 12:20 PM
Hi. What is the best way of checking for an empty string?


if len(temp)=0 then

'Or
if temp="" then


Does it make any difference? I would assume extra processing goes on for len() but some people seem to prefer it. Is there a reason?

OnErr0r
01-06-2008, 12:23 PM
String comparisons actually are more work. Len() is 6 instructions, LenB() is 5. Probably won't see much (any) difference between Len and LenB. But darn it, LenB is just l33ter. ;)

The reason Len(B) are faster is due to the fact that VB strings (BSTRs) keep track of string length in their header. Therefore your comparison is purely numeric.

the master
01-06-2008, 12:28 PM
Ahh. That makes sense. Ill make sure i stick with lenB() from now on.

Thanx

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum