Signature (Visual Basic / VBA)
Public Function ReplaceValue( _
ByVal vOriginal As Variant _
, ByVal vFind As Variant _
, ByVal vReplace As Variant _
) As Variant
Code 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
Original == Find: Return Replace
Original <> Find: Return Original
Parameters
| Parameter | Description |
|---|---|
| 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. |
Notes & Version History
| 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. |