Function Convert Values Class

EmptyToValue

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

Signature (Visual Basic / VBA)

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

Code Example

    Assuming
       Dim varEmpty As Variant
    for example
       EmptyToValue(varEmpty, 0) = 0
       EmptyToValue(EmptyValue, "N/A") = "N/A"
       IsNull(EmptyToValue(Null, 0)) = True
       EmptyToValue("Word", "N/A") = "Word"
       EmptyToValue(123456, 12) = 123456

Parameters

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