[Solved] Using Two “IsNot Nothing” in single If statement


For convenience, I removed the first loop with OrElse condition, defined the length variable for individual line so that I can add up later to find total length.
Remove:

If ((Area.DrainRightFound IsNot Nothing) OrElse (Area.DrainRightFound IsNot Nothing)) Then

Follow the following.


Dim FoundationLength As Double, FoundationArea As Double, **IndividualLength As Double**
                            For Each Area As DrainArea In Mydrainareacalc.MyDrainarea.Values
                                **IndividualLength = 0**
                                If Area.DrainLeftFound IsNot Nothing Then
                                    IndividualLength = Area.Length
                                    For Each LeftFound As FoundLayerDetail In Area.DrainLeftFound
                                        FoundationArea += LeftFound.LayerArea
                                    Next
                                End If
                                If Area.DrainRightFound IsNot Nothing Then
                                    IndividualLength = Area.Length
                                    For Each RightFound As FoundLayerDetail In Area.DrainRightFound
                                        FoundationArea += RightFound.LayerArea
                                    Next
                                End If
                                **FoundationLength += IndividualLength**

                            Next

solved Using Two “IsNot Nothing” in single If statement