Replace a Point3D with "Null" in VBScript

I am trying to replace specific Point3D points in a list with "Null" values. How can I do this in VBScript with the System.DBNull class?

I tried this after a conditional statement:

ptlist.Item(i) = System.DBNull

The above is unsuccessful. Does anyone know the correct syntax?

  • up

    Mateusz Zwierzycki

    Try this :

    Dim ptl As New list(Of Object)


    For i As Integer = 0 To 9 Step 1
    Dim np As New point3d(0, 2, i)
    ptl.add(np)
    Next

    Dim nu As system.Nullable = Nothing

    ptl(5) = nu
    a = ptl

    • up

      David Rutten

      First thing to understand is that Point3D is a structure (or Value Type). Structures are never null as their data is stored locally rather than the variable being a pointer to some location in memory where the actual data resides.

      There are however ways around this. One way is to 'box' the structure by creating a List(Of Object). System.Object is a Reference Type and therefore can be null, and it can also wrap around a Value Type such as Point3d. Boxing has always been possible in .NET but there's a sacrifice to be paid in terms of type-safety and performance.

      .NET 4.0 introduced nullable modifiers which allows you add nullability to Value Types. This is a good topic about value vs. reference and boxing vs. nullable: http://visualbasic.about.com/od/usingvbnet/a/nullabletypes.htm

      --

      David Rutten

      david@mcneel.com

      Poprad, Slovakia

      4