Function Convert Values Class

NullToValue

Replace Null values with some default value. Leave all other types of values unchanged.

Signature (Visual Basic / VBA)

Public Function NullToValue( _
      ByVal vValue As Variant _
    , ByVal vReplace As Variant _
    ) As Variant

Code Example

    NullToValue(Null, 0) = 0
    NullToValue(Null, "N/A") = "N/A"
    NullToValue("Word", "N/A") = "Word"
    NullToValue(123456, 12) = 123456

Parameters

Parameter Description
vValue The value which is to be returned as-is unless it is Null, in which case vReplace will be returned.
vReplace The value that will be returned if vValue is Null. Function returns vValue unchanged in all other cases.