Question

What, if anything, is the benefit of using

If StrComp(strVal1, strVal2, vbTextCompare) = 0 Then

as opposed to using

If strVal1 = strVal2 Then

If Option Compare Text is set at the module level, is there any difference?

I know StrComp handles null scenarios and <> scenarios, I am only interested in the situation where strVal1 and strVal2 have non-null valid strings assigned.

Was it helpful?

Solution

If Option Compare Text is set at the module level, is there any difference?

No. It simply offers a finer grained control (no module-level strategy commitments). However, if you can make such a commitment, go for the x = y option: less code is always better code.

OTHER TIPS

Since StrComp is comparing string (with cultural info), UpperCase and LowerCase are not taking care ... (so Hello is the same as hello). In the case of =, there will be different (Like using a Binary compare). If option compare text is at module level, there will be no difference (but you should use StrComp in case another guy delete it)...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top