I have an if statement like this:
If r1.Left < r2.Right AndAlso r2.Right < r1.Right AndAlso r2.Top + r2.Height > r1.Top Then
I am wondering if it is bad to have so many AndAlso‘s. It does work it’s just confusing to figure out whats happening. Is there a way of doing this test in a simpler way? or is this the correct way of doing things?
As far as I can tell, MSDN documentation doesn’t say anything about the maximum number of conditions that can be used in an
Ifstatement – so any limit is probably governed by available stack space and it’s highly improbable you would ever get anywhere near that.As for the practice: it’s not bad in coding terms but it can, as you say, become difficult to read. I personally tend to just use line continuations to make such statements more readable: