Checking Nulls

  • Thread starter Thread starter Atley
  • Start date Start date
A

Atley

Before I could just check for null, no matter what the variable type. How
do I check for null in different variable types such as Double, DateTime,
and Integer?

Any help is greatly appreciated.

Atley
 
That's Nothing in VB
If you are testing a primitive type (Integer, Double etc), you can use
IF val = Nothing Then
With objects it would be
If myObj Is Nothing Then

A problem here is that technically when you compare a primitive type to
Nothing it gets converted to an Object, so the result of this comparison is
not exactly what you want, but in most cases it will be.
 
I use

if (myvar is nothing) = False Then
' myvar is declared
Else
' myvar points to nothing
End if

Roberto
 
Back
Top