GenoPro Home
GenoPro Home  |  SDK Home  |  Report Generator  |  Support  |  Search  |  Help  |  Site Map

Skip Navigation Links.

Util.IsNothing Method

The IsNothing method returns a Boolean value indicating whether a variable has no data assigned to it. This method is very similar to the function IsNothing in VB.NET; the difference is the method IsNothing does check if the object is empty rather than just checking if the object exists.

For instance IsNothing(i.Pictures)will return true if there are pictures and false if there are no pictures. On the other hand, VB's function IsNothing(i.Pictures) will always return true because i.Pictures is an object.

The method IsNothing is very useful, yet not mandatory. The other alternative is to compare the object against its "empty value". For instance, an empty list (collection) of picture has a count of pictures equal to zero. An empty string can be compared to "".

Using the method IsNothing is more reliable and faster than comparing against the empty value. The following piece of code does determine if an individual has a picture. Comparing if the picture name against an empty string can produce incorrect results, as a picture without a name may exists.

' Determine if there is a primary picture
If (Not Util.IsNothing(i.Pictures.Primary)) Then
	' Your code there
End If

' Not recommended
If (i.Pictures.Primary.Name <> "") Then
	' Your code there
End If

In summary, the method IsNothing returns true in the following cases:

  1. The variable has never been initialized, and therefore empty.
  2. The variable is set to Nothing.
  3. The variable contains an empty string.
  4. The variable points to an object that is empty.
  5. The collection is empty. A collection is a list of items such as individuals, families, pictures, occupations, etc.


Dim strTest

Report.WriteBr Util.IsNothing(strTest)	' Returns true
strTest = "abc"
Report.WriteBr Util.IsNothing(strTest) ' Returns false
strTest = ""
Report.WriteBr Util.IsNothing(strTest) ' Returns true
Set strTest = Nothing Report.WriteBr Util.IsNothing(strTest) ' Returns true If (Not Util.IsNothing(i.Children)) Then ' The individual has children End If

See Also:
Collection Object


Copyright ┬ę 1998-2021. All rights reserved. GenoPro┬« and the GenoPro logo are registered trademarks.