VB script to removel null values from list

I am trying to remove the null values from a list of planes, and output the clean list of planes.

Sub RunScript(ByVal x As List(Of OnPlane))
Dim CleanList As New List (Of OnPlane)
Dim i As Integer
For i = 0 To x.Count() – 1
If x(i) = Nothing
Return
End If
CleanList.Add(x(i))
Next
A = CleanList
End Sub
  • up

    Dirk Anderson

    This should work:

    Sub RunScript(ByVal x As List(Of OnPlane))

    Dim CleanList As New List (Of OnPlane)

    For i As Int32 = 0 To x.Count() – 1
    If (x(i) <> Nothing) Then
    CleanList.Add(x(i))
    End If
    Next

    A = CleanList

    End Sub
    • up

      Tuan N. Tran

      You can also use the "Clean Tree" component.