Public Function ReplaceStringNTimes( _ ByVal vLine As Variant _ , ByVal vFind As Variant _ , Optional ByVal vReplace As Variant _ , Optional ByVal vCompare As Variant _ , Optional ByVal vNTimes As Variant _ ) As Variant
ReplaceStringNTimes("This is a test.", "s", "$", vbBinaryCompare, 2) = "Thi$ i$ a test." ReplaceStringNTimes("This is a test.", "s", "$") = "Thi$ is a test." ' Behavior #8See also:
Replace Function (Visual Basic) ReplaceString Function ReplaceStringRecursively Function ReplaceStringOnce FunctionvLine: The string in which occurrences of vFind are to be replaced with vReplace. Function returns Null if vLine is Null or cannot be fixed up to a String (Behavior #1).
vFind: The string which is to be replaced with vReplace. Function returns Null if vFind is Null or cannot be fixed up to a String (Behavior #2). Function returns vLine unchanged if vFind is an empty string (Behavior #3).
vReplace: The string which is to replace occurrences of vFind within string vLine. vReplace defaults to an empty string if it is missing or Null or cannot be fixed up to a String (Behavior #4). vReplace can be an empty string in which case all occurrences of vFind are removed from the string vLine (Behavior #5).
Note: This function works correctly with vReplace strings that contain the vFind string. For example, Chr$(10) can be replaced by Chr$(10)+Chr$(13) without the function getting into an infinite loop (Behavior #6).
vCompare: Specifies the type of comparison used to determine if strings match (Behavior #7). vCompare defaults to Binary comparisons if it is missing or Null or cannot be fixed up to a number (Behavior #8).
vNTimes: The maximum number of replacements to be performed (Behavior #9). vNTimes defaults to 1 (one) if it is missing or Null or cannot be fixed up to a number (Behavior #10).
v1.5 Note: This function has been superceded by the Replace function in Visual Basic 6.0. It is similar to the Replace function in Visual Basic, except that this function allows the vFind argument to be Null, in which case it returns Null. Visual Basic's Replace function will generate a runtime error if its Find argument is Null.
v1.5 Pro Change: The implementation of this function has been changed to use the Replace function in Visual Basic.
Copyright 1996-1999 Entisoft
Entisoft Tools is a trademark of Entisoft.