Share via


Nullable Types

With the nullable variable type, a standard value or a null (unknown or undetermined) value can be assigned to a variable. The addition of the nullable type to a variable creates an additional Boolean (True/False) component to the variable. This creates essentially a two-part variable, consisting of HasValue (with a value of True or False) and Value (of the original variable’s type). When HasValue is True, the Value of the variable is returned; however if HasValue is False, Null is returned.

Nullable variables are useful for creating database forms where some fields are optional and may not contain data. When coding, you may check for the existence of data in a field before attempting to use that data. The nullable property is read-only and cannot be set by the users.

A nullable type variable can be used just as you use a regular value type variable. Conversion between a regular variable and a nullable type variable of the same type is automatic.