Signature (Visual Basic / VBA)
Public Function ReplaceValueOfType( _
ByVal vOriginal As Variant _
, ByVal vFind As Variant _
, ByVal vReplace As Variant _
) As Variant
Code Example
ReplaceValueOfType(2%, 0%, 1%) = 2%
ReplaceValueOfType(0%, 0%, 1%) = 1%
ReplaceValueOfType(0%, 0!, 1!) = 0%
ReplaceValueOfType(0!, 0!, 1!) = 1!
IsNull(ReplaceValueOfType(Null, Null, 1)) = True ' #5
IsNull(ReplaceValueOfType(Null, 0, 1)) = True
IsNull(ReplaceValueOfType(0, 0, Null)) = True
Parameters
| Parameter | Description |
|---|---|
| vOriginal | The value whose value and data type are checked to see if they match vFind. Function returns vReplace if vOriginal equals vFind and VarType(vOriginal) equals VarType(vFind). Function returns vOriginal otherwise. vOriginal must be a numeric or string or Null value which is type-compatible with vFind. |
| vFind | The value whose value and data type are 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 both the value and data type of vOriginal matches that of 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 #5. |