<-- Previous || Up || Next -->

Replace Value Function
Convert Values Class

Public Function ReplaceValue( _
      ByVal vOriginal As Variant _
    , ByVal vFind As Variant _
    , ByVal vReplace As Variant _
    ) As Variant

"Replace One Value With Another Value"
Replaces some specific value with another value.
Returns all other values unchanged.
Generally only supports numeric and string values.

Examples:
    ReplaceValue(4, 0, -1) = 4
    ReplaceValue(0, 0, -1) = -1
    IsNull(ReplaceValue(Null, Null, "1")) = True ' #3
    IsNull(ReplaceValue(Null, 0, -1)) = True
    IsNull(ReplaceValue(0, 0, Null)) = True
See also:
    ReplaceValueOfType Function
    ReplaceVarTypeWithValue Function
Summary:
    Original == Find: Return Replace
    Original <> Find: Return Original
vOriginal: The value which is checked to see if it matches vFind. Function returns vReplace if vOriginal equals vFind. Function returns vOriginal if vOriginal does not equal vFind. vOriginal must be a numeric or string or Null value which is type-compatible with vFind.
vFind: The value which is compared to vOriginal to determine what should be returned. vFind must be a numeric or string or Null value which is type-compatible with vOriginal.
vReplace: The value which is returned instead of vOriginal if vOriginal matches vFind. vReplace must be a numeric, String, Empty, or Null value.
Note: Function performs Binary comparisons if vOriginal and vFind are strings.
Note: Function uses the Visual Basic "=" operator to determine if values match. Because of this, if either vOriginal or vFind are Null, no match will take place and vOriginal will be returned unchanged as in example #3.

Copyright 1996-1999 Entisoft
Entisoft Tools is a trademark of Entisoft.