Вы должны действительно использовать скобки для удобства чтения. Даже тогда сравнение уродливо.
If ((aEntityId IsNot Nothing And bEntityId IsNot Nothing) AndAlso (aEntityId = bEntityId)) Or (aEntityId Is Nothing And bEntityId Is Nothing) Then
If ((aCheckNumber IsNot Nothing And bCheckNumber IsNot Nothing) AndAlso (aEntityId = bEntityId)) Or (aCheckNumber Is Nothing And bCheckNumber Is Nothing) Then
evalcheck = True
Else
evalcheck = False
End If
Else
evalcheck = False
End If
Я предпочитаю этот метод лучше, хотя
Private Function NullableIntsEqual(ByVal a As Integer?, ByVal b As Integer?) As Boolean
If ((a IsNot Nothing And b IsNot Nothing) AndAlso (a = b)) Or (a Is Nothing And b Is Nothing) Then
Return True
Else
Return False
End If
End Function
Ваша строка проверки становится
evalcheck = NullableIntsEqual(aEntityId, bEntityId) And NullableIntsEqual(aCheckNumber, bCheckNumber)