vb.net null

If you have a conditional statement and you want to kill all numbers less Y my intuition tells me to set x to null which does not work.


    If x < y Then
      x = null

    Else
      x = x
      Print("Point passed" & x)
    End If


    A = x


_______________________________________________________________

If I set x to "null" it returns null because it is a string which is an invalid argument.
This works but what is the correct way to kill or make all values less than Y null?

    If x < y Then
      x = "null"

    Else
      x = x
      Print("Point passed" & x)
    End If


    A = x
 


   
  • up

    Damien Alomar

    There are certain data types in .Net that cannot be null (or Nothing which is the VB.Net keyword). Any number type (ints, doubles, singles, longs, etc) cannot be null. Those values all have a default value of 0 (or 0.0). Assigning Nothing to those variables just sets the value back to the default.

    Also, VB.Net is a Strongly Typed language, which mean two things, A) you must specify the type of a variable when its declared, and B) the type of the variable cannot change. So you don't really even have the option to assign a string to that variable either.
    4