Q:

Multiple compares within IF statement in Visual Basic

In my visual basic .net app I want to do comparison like
If myObject IsNot Nothing And myObject.property <> 0 Then
...
EndIf

The problem is that I get null reference exception when myObject is nothing. So I have to nest IF statements:
If myObject IsNot Nothing Then
    If myObject.property <> 0 Then
    ...
    EndIf
EndIf

Is it possible to do this comparison without nesting IFs?

A:

You have to use AndAlso (equivalent to && in C#). This is the logical operator performing the short-circuiting logical conjunction. And performs the logical operation without shortcircuit (equivalent to & in C#) and thus analyses both operands. 

